This chunk of code was found in a script someone else wrote that I was asked to edit. It doesn’t appear to be doing anything.. I’m wondering why on earth it was there and if something somewhere in the world would go terribly wrong if I remove it..
Am I missing something?
//begin mystery code - i have no idea what this chunk of code is doing..
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$i++;
}
}
//end mystery code
$result is not referenced anywhere else..
It does two things:
$iper row.$rowand finallyfalseinto it.So finally it sets:
$ito the number of rows.$rowtofalseBut do not wonder about crap code much. Improve it instead:
Also encapsulate
mysql_*calls so you can easily replace them later. You should also handle the error case if the query fails.