tags:

views:

45

answers:

2

I have a php file that has to be loaded as a web page. This page is 17Kb in size. It has a php mysql query script inside.

the problem now, sometimes my mysql_query() lines gives an error. When being refreshed, it works again. It just have an error sometimes on that same line. I check the query string and it was okay, for if that was the problem the error should happen all the time.

any idea?...

I was thinking maybe it was the file that has not been loaded completely. And if that so, anyone to help me?... thanks.

+1  A: 

You can use mysql_error() to get more details about the error that's currently occuring. Just below the line that triggers the error, add:

echo mysql_error();
Joel Alejandro
Remember to remove when going to production!
alex
A: 

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource."

Sound like you have a problem with mysql connection. Try the the following code, after you called connect function, try to print out the error message.

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
Darkerstar
ok, tried this.. and for some time it could not connect to the host. So is there a way to make a reconnection?
Reigel
most likely your host's mysql connection is maxed out. How busy is your site? If the connections are made by your own page then you might want to move to a better server. If not you should ask for server support. mysql_stat() will be also useful, it will return current active open connections server wide, of course that need a valid connection too. :)
Darkerstar