Connecting Tech Pros Worldwide Help | Site Map

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

Pratchaya
Guest
 
Posts: n/a
#1: Jul 25 '05
Hi Everyone

================================================== ============
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

or

PHP Warning: mysql_fetch_array(): supplied argument is not a valid
MySQL result resource in /var/www/html/website_in_server/showdata.php


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

Anyone can help me sir.. ?

thank you for advance

Andy Hassall
Guest
 
Posts: n/a
#2: Jul 25 '05

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


On 25 Jul 2005 12:11:19 -0700, "Pratchaya" <pratchaya@banana.co.th> wrote:
[color=blue]
>================================================= =============
>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[/color]

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.
[color=blue]
>I think problem source from php.ini or httpd.conf .[/color]

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
Michael Phipps
Guest
 
Posts: n/a
#3: Jul 26 '05

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


> I got error can't login to my code.[color=blue]
> and found error on /var/log/httpd/error_log like this[/color]

Have your database login details changed?


Pratchaya
Guest
 
Posts: n/a
#4: Jul 27 '05

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


No. sir

it same both code and database sir.

Closed Thread