From:             phpbugs at phormix dot com
Operating system: FreeBSD
PHP version:      5.2.6
PHP Bug Type:     MySQL related
Bug description:  Missing values on mysql_fetch_assoc

Description:
------------
mysql_fetch_assoc does not return certain values attached to their named
items in the array. mysql_fetch_array shows that the numbered entries
definitely have values attached to them, but for some reason these are not
being attached to the appropriate names.

For example, as below. The first field is "userid"
array[0] returns a value
array[userid] does not

however, when adding code to the query "userid as userid2"
array[0] returns a value
array[userid] does not
array[1] returns a value
array[userid2] returns a value

Reproduce code:
---------------
$myquery = "SELECT user.userid, user.userid as userid2, reputation,
username, usergroupid, birthday_search, email, parentemail,(options & 8) AS
coppauser, homepage, icq, aim, yahoo, msn, skype, signature, usertitle,
joindate, lastpost, posts, ipaddress, lastactivity, userfield.* FROM user
LEFT JOIN userfield AS userfield ON(userfield.userid = user.userid) LEFT
JOIN usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE 1=1 AND user.username LIKE '%jdoe%' ORDER BY username ASC LIMIT 0,
50";

$user_r = mysql_query($myquery);
print_r( mysql_fetch_array($user_r) );




Expected result:
----------------
Array ( [0] => 22768 [userid] => [1] => 22768 [userid2] => 22768 [2] => 10
[reputation] => 10 [3] => jdoe [username] => jdoe [4] ... etc

Actual result:
--------------
Array ( [0] => 22768 [userid] => [1] => 22768 [userid2] => 22768 [2] => 10
[reputation] => 10 [3] => jdoe [username] => jdoe [4] ... etc

(please note the missing userid)

-- 
Edit bug report at http://bugs.php.net/?id=45237&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45237&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45237&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45237&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45237&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45237&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45237&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45237&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45237&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45237&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45237&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45237&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45237&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45237&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45237&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45237&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45237&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45237&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45237&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45237&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45237&r=mysqlcfg

Reply via email to