Re: Troubled code (or my troubled brain)

From: Date: Sun, 02 Jul 2000 23:24:45 +0000
Subject: Re: Troubled code (or my troubled brain)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4407@lists.php.net to get a copy of this message
Try taking out the "" around $name. I think right now your code is looking for a value of $id that equals "$name" with the quotations. So, it should look like if ($id == $name) { echo "$count"; } else { echo "0"; } See if that helps.. I'm new to PHP but I think that's the problem. terranlune ----- Original Message ----- From: "Tyler Longren" <tyler.longren@midiowa.net> To: "PHP-General" <php-general@lists.php.net> Sent: Sunday, July 02, 2000 3:28 PM Subject: [PHP] Troubled code (or my troubled brain) > > Hello List, > > I'm having problems with some code of mine. I don't know why it doesn't > work. Here's the section that's troubled: > > if ($id == "$name") { > echo "$count"; > } > else { > echo "0"; > } > > No matter what, this is always 0. > > I think that I have something wrong somewhere else in my code however and > I don't know where it's at. So here's the rest of it (don't make fun of > the dirtiness): > > <? > echo "<Center><u><b>PHP > Code</u></b></center><Br>"; > $connection = mysql_connect("host", "user", "pass") or die > ("Unable to > connect to server."); > $db = mysql_select_db("cr0n", $connection) or die ("Unable to find > requested database."); > $result = mysql_query ("SELECT * FROM user_code WHERE language LIKE > 'php'"); > $numrows = mysql_num_rows($result); > while($row = mysql_fetch_array($result)) { > $description = $row["description"]; > $email = $row["email"]; > $type = $row["type"]; > $id = $row["id"]; > $language = $row["language"]; > $author = $row["name"]; > $date = $row["date"]; > $result2 = mysql_query("SELECT * FROM counter WHERE name = '$id''"); > while($row2 = mysql_fetch_array($result2)) { > $count = $row2["count"]; > $name = $row2["name"]; > } > echo "<table width=75% align=center bgcolor=#000000 cellpadding=0 > cellspacing=0><tr><td bgcolor=#000000><table width=100% border=0 > cellspacing=1 cellpadding=1 height=0%> > <tr> > <td height=15 bgcolor=#000000 colspan=2><A > href=\"viewcode.php?id=$id\"><font size=-1 color=#FFFFFF face=Arial, > Helvetica, sans-serif>$description</font></a></td> > </tr> > <tr> > <td bgcolor=#4A5A63 valign=top width=50% height=23>Author: <a > href=\"mailto:$email\"><font size=-1 > color=#000000 face=Arial, Helvetica, > sans-serif>$author</font></a></td> > <td bgcolor=#4A5A63 valign=top width=50% height=23>Date: $date</td> > </tr> > <tr> > <td bgcolor=#4A5A63 valign=top width=50% height=24>Category: $type</td> > <td bgcolor=#4A5A63 valign=top width=50% height=24>Views: "; > > //here's the troubled section > if ($id == "$name") { > echo "$count"; > } > else { > echo "0"; > } > echo > "</td></tr></table></td></tr></table><Br>"; > > } > if ($numrows == "0") { > echo "<center><font color=#000000 size=2 face=Arial, Helvetica, > sans-serif>No PHP code has been submitted yet!</font></center>"; > } > > mysql_free_result($result); > ?> > > If anybody has any idead, please let me know, this is really bothering me. > > Regards, > Tyler > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com

« previous php.general (#4407) next »