note 67512 deleted from function.mysql-fetch-array by bjori

From: Date: Wed, 23 Aug 2006 07:35:41 +0000
Subject: note 67512 deleted from function.mysql-fetch-array by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116201@lists.php.net to get a copy of this message
Note Submitter: solutions at lanetech dot co dot uk ---- This might be obvious to some... but this had me puzzling for a while! I needed to count the number of elements returned from a db query. I used $row = @mysql_fetch_array($result) and then a loop using count($row) as the control. I found it was doubling the number of elements because the default return of mysql_fetch_array returns BOTH the associative and numeric versions of the array! I changed the fetch to mysql_fetch_assoc and all is now well. Hope that saves somone a little time!

« previous php.notes (#116201) next »