PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known
PHP Snippet 1:
$hostName = "localhost";
$dbName = "test";
$userName = "test";
$password = "test1";
try {
$pdo = new PDO("mysql:host=$hostName;dbname=$dbName",$userName,$password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}