custom-error-messages.php : mysqli_connect « MySQL Database « PHP






custom-error-messages.php

 
$errors = array (
          "1045" => "Unable to authenticate user.",
          "2005" => "Unable to contact the MySQL server.",
          "2013" => "Lost MySQL connection."
                );
$link = @mysqli_connect("127.0.0.1", "root","", "mydatabase");

if (!$link) {
   $errornum = mysqli_connect_errorno();
   echo $errors[$errornum];
}
  
  








Related examples in the same category

1.In PHP 5 using the MySQLi extension
2.Discovering Which Extension Is Being Used
3.MySQL Connection Test
4.function mysql_connect() establishes an initial connection with the MySQL server.