#15111 [Com]: mysql_fetch_array() returns bad array

From: Date: Mon, 11 Oct 2004 12:56:36 +0000
Subject: #15111 [Com]: mysql_fetch_array() returns bad array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67411@lists.php.net to get a copy of this message
ID: 15111 Comment by: laboom at abv dot bg Reported By: compman86 at home dot com Status: Bogus Bug Type: MySQL related Operating System: Windows 2000 PHP Version: 4.1.1 New Comment: I have the same problem - I LIMIT the sql query to 15 but I get 18. I use "do{...} while ($myrow = mysql_fetch_array($result));" When I debug it I find out that $myrow contains more fields than needed - some of the fields are returned three times (twice as normal + 1 unnecessary). For example $myrow: 0 : "36939611" pl_id : "36939611" .. 9 : "yes" pl_train : "yes" 10 : "36939611" 11 : "Alexander Donchev" pl_name : "Alexander Donchev" ... Previous Comments: ------------------------------------------------------------------------ [2002-01-19 03:33:04] sander@php.net mysql_fetch_array contains each field twice (numeric, and with fieldnames). RTM on mysql_fetch_row, mysql_fetch_array, and mysql_fetch_assoc. ------------------------------------------------------------------------ [2002-01-18 23:59:35] compman86 at home dot com I have a table with 10 columns. I queried the mysql database to return only 5. I used mysql_fetch_array($queryID) to get an array of data to work with. When I did count(mysql_fetch_array($queryid)) it returned 8. When I did mysql_num_fields($queryid) it returned 5. Also, when I try to access the array returned from mysql_fetch_array as a numeric array, it doesn't work. It doesn't give warnings, but it doesn't give any data. Here is some sample code: $qid = mysql_query("SELECT a,b,c,d,e FROM table1"); echo mysql_fetch_array($qid); echo mysql_num_fields($qid); echo count(mysql_fetch_array($qid)); Thankyou for your time! =) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15111&edit=1

« previous php.bugs (#67411) next »