Occasional MySQL query Error in PHP
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开发者_如何学Go 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.
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();
"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());
}
精彩评论