The only problem with die is it litterally kills the script (stops it) so anything afterwards will not work.
Maybe somming like this would be better:
$conn = mysql_connect("ipaddress", "user", "pass")
If($conn){
MYSQL
STUFF
HERE
}else{
ERRORMESSAGE
}
Rest of code
I assume this should work cause unless you can connect to the DB $conn will be false.
But which method you use depends on what you want to do.