note 14024 deleted from ref.mysql by betz
| From: | betz@php.net | Date: | Wed, 21 Apr 2004 10:10:06 +0000 |
| Subject: | note 14024 deleted from ref.mysql by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-68423@lists.php.net to get a copy of this message | ||
Note Submitter: rupert@ditzed.org
----
Hi,
The problem with
extract(mysql_fetch_array($result));
is that it actually fetches two arrays, a number index array ($arr[0], $arr[1], $arr[2], ...) and an
associative (hash) array, ($arr["field1"], $arr["field2"],
$arr["field3"], ...), thus $arr actually contains two sets of data (as you have observed).
If you then try to push out all the data from $arr without explicitly naming those field ids, then
you WILL get your data appearing twice.
The full definition for mysql_fetch_array is as follows:
mysql_fetch_array ($result_id, [MYSQL_NUM|MYSQL_ASSOC])
Since MYSQL_NUM is equivalent to mysql_fetch_row, you have found that switching to mysql_fetch_row
works fine.
In fact, the only real reason you may want to use mysql_fetch_array is with the MYSQL_ASSOC option,
as this allows you to reference the fields in the associative array returned.