mysql_fetch_array strangeness
| From: | Jaxon | Date: | Mon, 22 Jan 2001 01:07:33 +0000 |
| Subject: | mysql_fetch_array strangeness | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35931@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to echo out the field names used as key values in a
mysql_fetch_array:
$link_id = mysql_connect("localhost", "root", $pass);
mysql_select_db("database", $link_id);
$result = mysql_query("select * from lists where id = 1", $link_id);
$rowData = mysql_fetch_array($result);
while (list($fieldName) = each($rowData))
{ echo "$fieldName,"; }
I'm expecting to get this:
id,listname,joinconfirm,leaveconfirm,homepage,author,canjoin,bannedemails,de
scription,subject,masteremail,
but instead getting this:
0,id,1,listname,2,joinconfirm,3,leaveconfirm,4,homepage,5,author,6,canjoin,7
,bannedemails,8,description,9,subject,10,masteremail,
Why are the index numbers for the array showing up? From the docs,
mysql_fetch_array should create an array of field names to field values...?
To make things worse, if I also echo the data:
while (list($fieldName, $fieldValue) = each($rowData))
{ echo "$fieldName,$fieldValue," ;}
Then a value is echoed after both the index number and the field value, eg:
0,1,id,1,1,testlist,listname,testlist, etc...
What am I doing wrong?
Regards,
Jaxon