Posted by ZeldorBlat on 12/15/05 20:39
Jim wrote:
> Some of the pages on my website was down for 1.5 hours the other day because
> the shared MySQL didn't work. Rather than having PHP returning an error, I
> would like the page to show anyway without any error messages but with an
> error e-mail sent to me. This is the code I'm using to connect to the
> database:
>
> $link = mysql_connect($db_host,$db_user,$db_password);
> if (!$link) { die('Could not connect: ' . mysql_error());}
> mysql_select_db($db_name) or die(mysql_error());
> $sql = "<cut>";
> $query = mysql_query($sql);
> $array = mysql_fetch_array($query);
> mysql_close($link);
>
> What do I do?
Well, let's take a look at what your code says to do when you can't
connect to the database:
if (!$link) {
die('Could not connect: ' . mysql_error());
}
Instead of dying, do something else. Like send yourself an email.
[Back to original message]
|