#19116 [Com]: mysql_fetch_array wont get associative values
| From: | jg at proz dot com | Date: | Fri, 21 Feb 2003 14:25:21 +0000 |
| Subject: | #19116 [Com]: mysql_fetch_array wont get associative values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-33838@lists.php.net to get a copy of this message | ||
ID: 19116
Comment by: jg at proz dot com
Reported By: bzink at crewercs dot com
Status: Bogus
Bug Type: MySQL related
Operating System: Linux and XP
PHP Version: 4.2.1
New Comment:
I don't think this bug is bogus, just difficult to reproduce. I also
experienced this bug, using PHP 4.3.0, when using mysql_fetch_array on
a "SELECT *" result set from a table with a large number of columns.
Only the first element of the returned array had the numeric indexed
value set but the associative value empty. To add to the weirdness,
the value that should have been available from the associative key was
stuck in numeric index number 64, which did not have a corresponding
associative key.
Changing the query to select only the columns that I actually needed
resolved the problem for me.
Previous Comments:
------------------------------------------------------------------------
[2002-08-27 01:30:53] georg@php.net
Ups..
I meant the the associative array has case sensitive keys.
------------------------------------------------------------------------
[2002-08-27 01:26:01] georg@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php
Thank you for your interest in PHP.
Please remember, that the mysql_fetch_array is case sensitive. To see
the contents of $row use var_dump($row).
------------------------------------------------------------------------
[2002-08-26 22:17:55] bzink at crewercs dot com
Note: This fails in 4.2.1 and 4.2.2
mysql_connect($host, $user, $pass) or
die("could not connect");
mysql_select_db($database);
$result = mysql_query("SELECT * FROM $table");
while ($row = mysql_fetch_array($result)) {
printf ("Name: " . $row[1] . "--" . $row["first"] .
"--" . "<br>"
);
}
mysql_free_result($result);
Data is placed in the numeric indices, but NOT the associative ones.
This fails on dedicated web hosting (JTL net) as well as my on version
running on XP. $row[1] gets data, but $row["first"] does not. Also does
not work if add the MYSQL_ASSOC parameter nor does the
mysql_fetch_assoc() work.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19116&edit=1