Bug #69673 [NEW]: 'mysql_fetch_array' numeric index results corrupted for SELECT numeric.

From: Date: Wed, 20 May 2015 14:40:52 +0000
Subject: Bug #69673 [NEW]: 'mysql_fetch_array' numeric index results corrupted for SELECT numeric.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192787@lists.php.net to get a copy of this message
From: kpielorz at tdx dot co dot uk Operating system: FreeBSD 10.1-R-p19 PHP version: 5.6.9 Package: MySQL related Bug Type: Bug Bug description:'mysql_fetch_array' numeric index results corrupted for SELECT numeric. Description: ------------ The function 'mysql_fetch_array()' should (by default) return an array with a numeric index, and a column name index. A query which includes a "SELECT number" - e.g. "SELECT 1234" in any column corrupts the index count for subsequent columns. Test script: --------------- $qTemp = mysql_query( "SELECT a, b, c FROM test" ); $rTemp = mysql_fetch_array( $qTemp ); print_r( $rTemp ); Result: Array ( [0] => apple [a] => apple [1] => banana [b] => banana [2] => cherry [c] => cherry ) (Correct) But, change the query to: "SELECT 7000, a, b, c FROM test" and the resultant 'print_r' is now: Array ( [0] => 7000 [7000] => 7000 [7001] => apple [a] => apple [7002] => banana [b] => banana [7003] => cherry [c] => cherry ) This is wrong. The "SELECT 7000" has polluted the numeric index. If you use "SELECT a, b, 7000, c" - the index from the 3rd column onwards then gets polluted. The same code above works perfectly under PHP 5.4.3 - but produces the incorrect result above with PHP 5.6.9 -- Edit bug report at https://bugs.php.net/bug.php?id=69673&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69673&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69673&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69673&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69673&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69673&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69673&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69673&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69673&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69673&r=support Expected behavior: https://bugs.php.net/fix.php?id=69673&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69673&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69673&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69673&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69673&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69673&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69673&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69673&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69673&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69673&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69673&r=mysqlcfg

« previous php.bugs (#192787) next »