$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]; }