PDO et exceptions

PDO et exceptions - PHP - Programmation

Marsh Posté le 15-03-2009 à 00:04:13    

Bonjour, je pensais avoir géré correctement la connexion à ma base Mysql avec PDO, en  gérant les erreurs avec des exceptions :

Code :
  1. $user="****";
  2. $pass="******";
  3. $host="monserveur.fr";
  4. $dsn="mysql:host=".$host.";dbname=gmp";
  5. //Connection à la DB
  6. try
  7. {
  8.     $dbh=new PDO($dsn,$user,$pass);
  9. }
  10. catch (PDOExeption $e)
  11. {
  12.     die("Erreur ! Connection serveur SQL GMP impossible !" );
  13. }


 
Ce soir, le serveur mysql est HS, et dobc j'aurai du avoir "Erreur ! Connection serveur SQL GMP impossible !", mais j'ai  

Code :
  1. Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2005] Unknown MySQL server host 'monserver.fr' (2)' in /var/www/html/gmp/Gestiut/Includes/db/connect.php5:23 Stack trace: #0 /var/www/html/gmp/Gestiut/Includes/db/connect.php5(23): PDO->__construct('mysql:host=*****', '****', '****') #1 /var/www/html/gmp/Gestiut/Includes/not_logged/check_login_teacher.inc.php5(12): require('/var/www/html/g...') #2 /var/www/html/gmp/Gestiut/index.php5(223): include('/var/www/html/g...') #3 {main} thrown in /var/www/html/gmp/Gestiut/Includes/db/connect.php5 on line 23


 
Pourquoi le try/catch ne marche pas ??


---------------
Gamertag : Getget94 - PSN : Getget1980 - Nintendo Network : Getget1980 - Uplau : Getget1980
Reply

Marsh Posté le 15-03-2009 à 00:04:13   

Reply

Marsh Posté le 15-03-2009 à 00:51:23    

C'est bon, je suis un boulet, je sais pas écrire exCeption :/


---------------
Gamertag : Getget94 - PSN : Getget1980 - Nintendo Network : Getget1980 - Uplau : Getget1980
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed