Every once in a while, my MySQL server hiccups and doesn't return a few of the queries on the page. Then it shows those big ugly warnings, which I don't want my visitors to see.
Would it be possible to display a kind error message whenever the server hiccups telling the user to try again instead of seeing those ugly warning messages...
I know how to put an error message in when the MySQL server doesn't respond at all, but when the server hiccups, about half of the queries are returned and half of them aren't.
If you stick the @ sign in front of any function it supresses any error message going. You could try this for the mysql stuff:
The same principle can be applied to your mysql_connect and mysql_select_db functions.
if (!$result = @mysql_fetch_result($sql))
die ("A database error occurred.");
Thanks. I'm going to go put that in my code right now!
This is what I usually do to handle warnings and errors with MySQL:
Hope that helps.
$result = mysql_query("SELECT Foo from Bar") or die(mysql_error_msg());
echo "An error occured in the process:". mysql_error();