Troubled code (or my troubled brain)

From: Date: Sun, 02 Jul 2000 22:28:41 +0000
Subject: Troubled code (or my troubled brain)
Groups: php.general 
Request: Send a blank email to php-general+get-4403@lists.php.net to get a copy of this message
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

« previous php.general (#4403) next »