try { $dsn = "mysql:dbname=testdb;host={$db_host1}"; $dbh = new PDO($dsn, $db_username, $db_password); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); }