Bug #69673 [Opn->Csd]: 'mysql_fetch_array' numeric index results corrupted for SELECT numeric.

From: Date: Tue, 09 May 2017 11:11:19 +0000
Subject: Bug #69673 [Opn->Csd]: 'mysql_fetch_array' numeric index results corrupted for SELECT numeric.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209023@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69673&edit=1 ID: 69673 Updated by: fjanisze@php.net Reported by: kpielorz at tdx dot co dot uk Summary: 'mysql_fetch_array' numeric index results corrupted for SELECT numeric. -Status: Open +Status: Closed Type: Bug Package: MySQL related Operating System: FreeBSD 10.1-R-p19 PHP Version: 5.6.9 -Assigned To: +Assigned To: fjanisze Block user comment: N Private report: N New Comment: This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Previous Comments: ------------------------------------------------------------------------ [2015-05-20 14:40:50] kpielorz at tdx dot co dot uk 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 this bug report at https://bugs.php.net/bug.php?id=69673&edit=1

« previous php.bugs (#209023) next »