Using the Error Control Operator
The error control operator can be used to prevent PHP from displaying an error message in the user’s browser when the attempt to connect to the MySQL server fails. In the real world, this is the more common requirement. The error control operator is an @ sign placed next to the function call like this:
$conn = @mysql_connect('servername' , 'username' , 'password');
Using the die function
Another common real world practice is to use the die function to terminate the program and display a message. Without the connection to the database, it’s most likely that there’s no point in continuing!
$conn = @mysql_connect('servername' , 'username' , 'password') or die("Connection failed");