View Single Post
Old 11-18-2012, 01:16 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This is wrong: while($row = mysql_fetch_assoc($query));
A semi-colon at the end of a branch is true once and only once, and with loops its the last item of the collection (you can see it in a foreach for example). In a while, the control condition is false or null, so doing that above will assign null to $row regardless of how many records you have.

Either remove the while loop (assuming id is PK you'll only have one record anyway) or remove the semi-colon.

So never use a semi-colon on a branch, it will definitely come back again in the future, but now you know to look for it. Since its true once and only once, if (false); is considered true, so if you see an obvious false condition evaluating true, check that it has no semi-colon at the end of the branch.
Fou-Lu is offline   Reply With Quote