HubsInfo Network

PHP try/catch and fatal error when mysql is down!

0 Members and 1 Guest are viewing this topic.

PHP try/catch and fatal error when mysql is down!
« on: September 20, 2016, 11:25:56 PM »
Code: [Select]
try{
   $db = new PDO('mysql:host='.$host.';port='.$port.';dbname='.$db, $user, $pass, $options);
}

Code: [Select]
$db = new PDO('mysql:host='.$host.';port='.$port.';dbname='.$db, $user, $pass, $options) or die("Cannot Create PDO!");
Code: [Select]
$db = new PDO('mysql:host='.$host.';port='.$port.';dbname='.$db, $user, $pass, $options) or ($GLOBALS['errors'][] = "Cannot Create PDO!");