$dbcnx = mysql_connect("localhost", "user", "password");
if (!$dbcnx) {
echo "<p>Unable to connect to the MySQL Server</p>";
exit ();
}
if (!mysql_select_db("yourdatabase")){
echo "<p>Unable to connect to the database at this time</p>";
exit();
}
Hmm.. i didnt know i was that unclear i think i did say do not have it twice but anyway. Basically it will just be parsed anyway so it will select the database but if false will return the error, and exit the script.
Also you dont need the parenthesis for the echo statement its just an extra load on the server.