note 81147 deleted from language.exceptions by bjori

From: Date: Fri, 28 Nov 2008 17:31:08 +0000
Subject: note 81147 deleted from language.exceptions by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147090@lists.php.net to get a copy of this message
Note Submitter: webmaster at asylum-et dot com ---- According to Mo PDO exeptions do not currently extend the base Exception class and will not be caught by try {...} catc... I am unsure what version that pertains to but I am running Windows XP SP 2, Apache 2.2.4.0, PHP 5.2.5.5 and it seems to work just fine. See the code below. <?php $user='username here'; $pass='user pass here'; $dbase='database name here'; try { $dbh = new PDO('mysql:host=localhost;dbname='.$dbase, $user, $pass); echo 'Connection opened'; } catch (Exception $e) { die("Error!: " . $e->getMessage() . '<br/>'."\n"); } ?> Outputs: Error!: SQLSTATE[28000] [1045] Access denied for user 'username here'@'localhost' (using password: YES) Error!: SQLSTATE[28000] [1045] Access denied for user 'username here'@'localhost' (using password: NO) Error!: SQLSTATE[42000] [1049] Unknown database 'database name here' These are exactly the errors I would expect to see so my guess is that in one of the versions between what Mo had been using and current this issue has been fixed.

« previous php.notes (#147090) next »