I’m trying to catch the error on the database connection but I get the an error when I enter a wrong host name only, here’s my code :
try
{
$mysqlconnection = new PDO('mysql:host=localshost;dbname=test', 'root', '');
}
catch (Exception $ex)
{
die('Erreur : ' . $ex->getMessage());
}
And here’s the error I get :

Why do I get this error ONLY if I set a wrong hostname ?
You might want to turn the exceptions on and use
PDOExceptionfor the caught exception.For me it outputs