Re: About PHP::: Error/Problem PHP Warning: mysql_fetch_array():
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: About PHP::: Error/Problem PHP Warning: mysql_fetch_array():

From: Andy Hassall <andy@andyh.co.uk>
Date: Mon Jul 25 2005 - 21:55:57 CEST

On 25 Jul 2005 12:11:19 -0700, "Pratchaya" <pratchaya@banana.co.th> wrote:

>==============================================================
>About PHP::: Error/Problem PHP Warning: mysql_fetch_array():
>==============================================================
>
>In the past i use my code/script work fine with
>Mandrake 9.1 - 10.1 ( + apache ,mysql )
>
>Now i move to redhat EL4 with the same code/script
>
>I got error can't login to my code.
>and found error on /var/log/httpd/error_log like this
>
>PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL
>result resource in /var/www/html/website_in_server/showdata.php

 This means you did not check whether a previous mysql_* call (probably
mysql_query) was successful, and you continued anyway despite receiving "false"
as the return value.

>I think problem source from php.ini or httpd.conf .

 No, it's missing error handling in your showdata.php file.

 Check for whether the mysql_query call returned false - if it did, use
mysql_error() to display the error.

 A simple way of doing this is:

$result = mysql_query($sql)
    or die(mysql_error());

 This is not very user friendly, but it does stop the script going any further
past an error, and tells you what the error is.

 Once you've got that sorted you would be better off changing it to present a
more user friendly message rather than the raw underlying error.

 If you don't understand the error that the mysql_error() function produces
here, then post that error back again, with a _short_ extract of the code
around the error, and someone here may be able to help you with the actual
problem.

-- 
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Received on Mon Oct 17 21:18:04 2005