I'm getting an error no matter how I do the error checking (I'm not worried about the error, I presume it's a database issue), but the PDO version resolves MUCH slower (~5 minutes) than the mysql_() one. ...? Also, I know I could just rewrite the mysql_() version to not use die() and accomplish the same thing, but I'm a fan of PDO and the majority of my code uses it.
Code: Select all
try
{
$dbh = new PDO("mysql:host=$forumdbhost;dbname=$forumdatabase", $forumdbuser, $forumdbpass);
}
catch (PDOException $e) { echo '<p>Database is down.</p>'; }Code: Select all
if (!($db = mysql_connect($forumdbhost, $forumdbuser, $forumdbpass , $forumdatabase))){
die("Can't connect to database server.".mysql_error());
}else{
// select a database
if (!(mysql_select_db($forumdatabase,$db))){
die("Can't connect to database.");
}
}SQLSTATE[HY000] [2003] Can't connect to MySQL server on '***.****.com' (110)