Bugfixes and coding

I’ve spent the last couple of days bugfixing some code I wrote for the church website and writing some new code for various things. Had a superb headache while chasing one extremely weird bug just now, the piece of code below was never giving me more than 1 line of printout (which is weird, as mysql_num_rows() gave 33, not 1).

while ($row = mysql_fetch_array ($result));
{
print “nothing”;
print_r ($row);
}

Know what it was? My eyes hurt so much I missed it every time I prodded (over 35 minutes prodding!), that little innocent looking semi-colon on the end of the while() statement. Remove that, and everything works.

Don’t get caught out by this like I did 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.