I don't get you...
If you can't connect to the database it'll time out your script and exit?
If so use the die() function:
..
..
$connect_db = mysql_connect ("<mysql server>", "<username>", "<password>");
if (!$connect_db) die ("Couldn't connect to database");
..
..
If not we ned details.
-J