0

i have PHP Version 5.2.8 on my windows 2003 server, i am trying to connect with database

$dbh = new PDO("mysql:host=localhost;port=3306;dbname=$db_name", $db_user, $db_pass);

but when i use this statement i got following error

   Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'
 in bin\db.php:14 Stack trace: #0 bin\db.php(14): 
PDO->__construct('mysql:host=loca...', 'root', '123') #1 
main.php(4): include_once('C:\Inetpub\wwwr...') #2
 {main} thrown in bin\db.php on line 14

how can i fix this problem?

Thanks

air
  • 6,136
  • 26
  • 93
  • 125
  • possible duplicate of [PDOException “could not find driver”](http://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver) – a'r Feb 09 '11 at 13:36
  • i check this, but this also did't work... – air Feb 09 '11 at 14:00

2 Answers2

2

You must remove the ; on this line in php.ini :

;extension=php_pdo_mysql.dll
extension=php_pdo_mysql.dll 
A.Baudouin
  • 2,855
  • 3
  • 24
  • 28
  • i check already this before posting question , its without ; and also i have php_pdo_mysql.dll in ext directory... but in my php_info it shows like this... PDO drivers sqlite2 – air Feb 09 '11 at 13:37
  • Have you restarted the web server? Maybe it doesn't use the these settings yet... – Mathias E. Feb 09 '11 at 14:11
  • are you sure you're editing the php.ini that your script is actually using? You can check that with phpinfo() – Sebastián Grignoli Jun 29 '11 at 17:00
0

If you're upgrading PHP, be sure to check your environment variable information, especially your `PATH, and reboot if you change it.

I was using a php.ini file from a different directory. As Sebastian Grignoli suggests, check your phpinfo() results for the location of the php.ini it's using.

Littm
  • 4,923
  • 4
  • 30
  • 38
BitsAndBytes
  • 815
  • 1
  • 9
  • 13