here is a good sample for you from php manual:
Code:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password') or die (mysql_error());
db_selected = mysql_select_db('db_name', $link) or die (mysql_error());
or die() is not recommended for use in live production.