1$conn = mysqli_connect( '<server>', '<username>', '<password>', '<database-name>');
2if (!$conn) {
3 // whatever processing you want to do upon error in connection
4 // like log error or send an email to admin
5 // I am just printing the error at the moment.
6 echo mysqli_connect_errno() . ":" . mysqli_connect_error();
7 exit;
8}
9