note 67512 added to function.mysql-fetch-array
| From: | solutions at lanetech dot co dot uk | Date: | Thu, 08 Jun 2006 12:32:12 +0000 |
| Subject: | note 67512 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-113831@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 85.116.0.130
Probable Submitter: 81.154.104.44
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit -- http://master.php.net/note/edit/67512
Del: integrated -- http://master.php.net/note/delete/67512/integrated
Del: useless -- http://master.php.net/note/delete/67512/useless
Del: bad code -- http://master.php.net/note/delete/67512/bad+code
Del: spam -- http://master.php.net/note/delete/67512/spam
Del: non-english -- http://master.php.net/note/delete/67512/non-english
Del: in docs -- http://master.php.net/note/delete/67512/in+docs
Del: other reasons-- http://master.php.net/note/delete/67512
Reject -- http://master.php.net/note/reject/67512
Search -- http://master.php.net/manage/user-notes.php