Jump to content

[SOLVED] Mystery number being added??


galvin

Recommended Posts

I have the following code...

 

$user_set = mysql_query("SELECT * FROM users", $connection);
if (!$user_set) {
die("Database query failed: " . mysql_error());
}

$userResArray = array();
$userCount = 0;

while ($users = mysql_fetch_array($user_set)) {

$userRow = "<tr><td class="name">{$users["firstname"]}" . " " . "{$users["lastname"]}<br/><img src=\"http://gdoot.com/gsfl/images/user_{$users["userid"]}.jpg\" /> <span class=\"record\">RecordPlaceHolder</span></td>";

 

 

...which when outputted in the browser is causing seemingly random numbers to appear after the class of "name." (in the outputted table row).  For example, the first row outputted has "class = "name7"". 

 

Where is that 7 coming from?!?!?!?!  It should just be "class = "name"".

 

Only the last row (which is about row 30) has it correctly (i.e. class =  "name").  Every other row before that has a random number immediately after "name".

 

Anyone have any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/134643-solved-mystery-number-being-added/
Share on other sites

you have to escape your double quotes just like the rest of the line:

$userRow = "<tr><td class=\"name\">{$users["firstname"]} {$users["lastname"]}<br/><img src=\"http://gdoot.com/gsfl/images/user_{$users["userid"]}.jpg\" /> <span class=\"record\">RecordPlaceHolder</span></td>";

FYI, I just changed the class in code to be "class = \"nam\"" and everything outputted as just "nam" (as it should).  I then put it back to "class = \"name\"" and it comes back with random numbers (i.e. class = name8).

 

Seems like the "e" in "name" is causing problems somehow.  I guess I can just rename the class to "nam" instead of "name" but if anyone knows what might cause that, I'm very curious.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.