PDOException not being caught?

后端 未结 2 1580
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 03:10

I\'m getting the following error in PHP:

Fatal error: Uncaught exception \'PDOException\' with message \'SQLSTATE[HY000] [2003] Can\'t connect to MySQL serve         


        
相关标签:
2条回答
  • 2020-12-07 03:32

    Turn on error_reporting and check the errors.

    ini_set('display_errors', true);
    error_reporting(E_ALL);
    

    May be there is a fatal error, before that line, or maybe PDO is not available.

    0 讨论(0)
  • 2020-12-07 03:43

    The only thing I can think of is if you're inside a namespaced class, and should use \PDOException instead of PDOException.

    0 讨论(0)
提交回复
热议问题