Handling PDO Exceptions

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I'm just starting to use PDO for the first time under PHP 5.1.  But
something doesn't work right in the following situation:

try {
    $dbh = new PDO(...);
} catch (PDOException $e) {
    print("Error!" . $e->getMessage());

If an error occurs in constructing the new PDO instance, e.g., because
a wrong username/password, then the error is not printed.  The
application just dies.  PDO works fine on my installation when there
are no errors.  What do I have to do to see the error message when a
PDO exception occurs in such a try/catch block?


Site Timeline