note 14024 added to ref.mysql.php

From: Date: Fri, 13 Jul 2001 17:23:25 +0000
Subject: note 14024 added to ref.mysql.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15343@lists.php.net to get a copy of this message
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. http://www.php.net/manual/en/ref.mysql.php

« previous php.notes (#15343) next »