Use something like this:
$link_id = @mysql_connect("host","user","pass") or die(header("Location: error.php?error=database"));
This has to be put at the before any headers are sent, though, before in your page. It'll redirect to an error page when it can't connect. You can have a generic error page, or customize it based on the $error that is passed to it.
---John Holmes...