#46019 [NEW]: mysqli_result::fetch_array problem

From: Date: Sun, 07 Sep 2008 23:30:47 +0000
Subject: #46019 [NEW]: mysqli_result::fetch_array problem
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1140@lists.php.net to get a copy of this message
From: nothinghere at gmx dot net Operating system: Linux PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: mysqli_result::fetch_array problem Description: ------------ The output of the examples are slightly misleading because you can see 3 lines of output. The description of mysqli_result::fetch_array say that it will return only one row or NULL. But there is now while of for loop in the examples to put the three lines of the result in the array. That's why the code examples can't work and give only the last line of the result. Reproduce code: --------------- <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID LIMIT 3"; $result = $mysqli->query($query); $row = $result->fetch_array(MYSQLI_ASSOC); print_r($row) $result->close(); $mysqli->close(); ?> Expected result: ---------------- Array ( [0] => Array ( [Name] => Kabul [CountryCode] => AFG ) [1] => Array ( [Name] => Qandahar [CountryCode] => AFG ) [2] => Array ( [Name] => Herat [CountryCode] => AFG ) ) Actual result: -------------- Array ( [Name] => Kabul [CountryCode] => AFG ) -- Edit bug report at http://bugs.php.net/?id=46019&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46019&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46019&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46019&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46019&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46019&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46019&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46019&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46019&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46019&r=support Expected behavior: http://bugs.php.net/fix.php?id=46019&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46019&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46019&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46019&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46019&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46019&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46019&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46019&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46019&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46019&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46019&r=mysqlcfg

« previous php.doc.bugs (#1140) next »