call the mail function if the db connect fails. This may send you lots of emails as it will send you another one everytime someone hits the site when the db is down. Alternatively you could write to a file after the first email is sent then check it on all db connect failures. Don't forget to delete the file afterwards though or else it won't email you the next time. Could be something like this.
<?php
$conn=mysql_connect($host, $user, $pass);
if(!$conn) {
$file='/home/httpd/mysite/db_con_check');
$email='you@yoursite.com';
if(!file_exists($file)) {
shell_exec('> '.$file);
mail($email,'DB Connection','The DB failed at'.date('r'));
}
}
?>
Looking at this now it looks a little messy.
Also, this only works on a *nix box. If you need a platform independent version change the
<?php
shell_exec('>'.$file)
?>
to
<?php
fwrite(fopen($file,"w+"," ");
fclose($fp);
?>
HTH