#41303 [Opn->Bgs]: mysql_fetch_array returns empty array

From: Date: Mon, 07 May 2007 03:07:15 +0000
Subject: #41303 [Opn->Bgs]: mysql_fetch_array returns empty array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112334@lists.php.net to get a copy of this message
 ID:               41303
 Updated by:       scottmac@php.net
 Reported By:      admin at shadyindustries dot biz
-Status:           Open
+Status:           Bogus
 Bug Type:         MySQL related
 Operating System: Windows XP and Unix
 PHP Version:      4.4.7
 New Comment:

.


Previous Comments:
------------------------------------------------------------------------

[2007-05-07 01:50:41] dayseye at 21cn dot com

should print() be print_r() ?

------------------------------------------------------------------------

[2007-05-06 12:25:47] admin at shadyindustries dot biz

Description:
------------
mysql_fetch_array and mysql_fetch_assoc return empty arrays when, for
the same query, mysql_num_rows returns 5 - the correct number.
also notable, the mysql_affected_rows causes a server malfunction for
the same query.

I have tested it both on my 
public webserver (unix, unknown webserver, PHP 4, MySQL 4) and my home
computer (Windows XP, Apache2, PHP 5, MySQL 5), 
thus this problem would appear to not be related to just one
circumstance.

The really weird thing is that phpMyAdmin can read the database
perfectly.

Reproduce code:
---------------
<?php

		$con = mysql_connect("####" ,"####" ,"####");
		if (!$con) {
			trigger_error("Unable to connect to mysql, MYSQL ERROR: " .
mysql_error(),E_USER_ERROR);
		}
		if (!mysql_select_db("NuevasIslas", $con)) {
			trigger_error("Unable to open database, MYSQL ERROR: " .
mysql_error(),E_USER_ERROR);
		}

while($row = mysql_fetch_array(mysql_query("SELECT * FROM
jaydev_config"))) { 
	$config[$row['name']] = $row['value']; 
}

print "$config";

//print mysql_fetch_array(mysql_query("SELECT * FROM
jaydev_config"));

?>

Expected result:
----------------
Array
(
[enabled_login] => 0
[enabled_register] => 1
[server_name] => JayDev
[url_base] => http://ni.shadyindustries.biz/jaydev/
[url_forum] => http://forum.shadyindustries.biz/viewforum.php?f=4
)  


Actual result:
--------------
Array


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41303&edit=1


Thread (6 messages)

« previous php.bugs (#112334) next »