|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-05-09 11:11 UTC] fjanisze@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: fjanisze
[2017-05-09 11:11 UTC] fjanisze@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
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