Skip to content

Instantly share code, notes, and snippets.

@frozonfreak
Last active December 22, 2015 19:19
Show Gist options
  • Save frozonfreak/6518922 to your computer and use it in GitHub Desktop.
Save frozonfreak/6518922 to your computer and use it in GitHub Desktop.
php pdo db connection check
try{
$db = new PDO(DB_STRING, DB_USER, DB_PASSWORD,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$response = array("status" => 1,"message"=> "DB Connection Succesfull");
die(json_encode($response));
}
catch(PDOException $ex){
$response = array("status" => 0,"message"=> "DB Connection Failed");
die(json_encode($response));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment