#24879 [Opn->Fbk]: Some data lost in returned array by mysql_fetch_array
| From: | sniper@php.net | Date: | Thu, 31 Jul 2003 18:33:28 +0000 |
| Subject: | #24879 [Opn->Fbk]: Some data lost in returned array by mysql_fetch_array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-45127@lists.php.net to get a copy of this message | ||
ID: 24879
Updated by: sniper@php.net
Reported By: sm at grand-prix dot ru
-Status: Open
+Status: Feedback
Bug Type: MySQL related
Operating System: Linux RedHat 9
PHP Version: 4.3.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Also let us know what mysql version you're using,
and what configure line was used to configure PHP.
Previous Comments:
------------------------------------------------------------------------
[2003-07-31 05:26:09] sm at grand-prix dot ru
Description:
------------
In some cases mysql_fetch_array returns numbered array element, but
does'nt returns it's named copy.
This script was tested as a part of vbulletin's code.
Bug: in the first case $user[userid] is empty, but $user[0] contains
correct data. For other user - 2'nd case - all is OK. Behavior depends
from data, returned by mysql.
Reproduce code:
---------------
$query_string = "SELECT *,FROM_UNIXTIME(joindate) AS
joindate,FROM_UNIXTIME(lastvisit) AS
lastvisit,FROM_UNIXTIME(lastactivity) AS
lastactivity,FROM_UNIXTIME(lastpost) AS lastpost,
avatar.avatarpath,NOT
ISNULL(customavatar.avatardata) AS hascustomavatar
FROM user
LEFT JOIN avatar ON
avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON
customavatar.userid=user.userid
WHERE user.userid=412";
$res = mysql_query($query_string,$link_id);
$user = mysql_fetch_array($res);
print_r($user);
$query_string = "SELECT *,FROM_UNIXTIME(joindate) AS
joindate,FROM_UNIXTIME(lastvisit) AS
lastvisit,FROM_UNIXTIME(lastactivity) AS
lastactivity,FROM_UNIXTIME(lastpost) AS lastpost,
avatar.avatarpath,NOT
ISNULL(customavatar.avatardata) AS hascustomavatar
FROM user
LEFT JOIN avatar ON
avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON
customavatar.userid=user.userid
WHERE user.userid=287";
$res = mysql_query($query_string,$link_id);
$user = mysql_fetch_array($res);
print_r($user);
Expected result:
----------------
Array (
[0] => 412
[userid] => 412
[1] => 6
[usergroupid] => 6
[2] => SM_1
[username] => SM_1
.......
Array (
[0] => 287
[userid] => 287
[1] => 6
[usergroupid] => 6
[2] => SM
[username] => SM
.......
Actual result:
--------------
Array (
[0] => 412
[userid] =>
[1] => 6
[usergroupid] => 6
[2] => SM_1
[username] => SM_1
.......
Array (
[0] => 287
[userid] => 287
[1] => 6
[usergroupid] => 6
[2] => SM
[username] => SM
.......
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24879&edit=1