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

2
  • possible duplicate of PDOException “could not find driver” Commented Feb 9, 2011 at 13:36
  • i check this, but this also did't work... Commented Feb 9, 2011 at 14:00

2 Answers 2

2

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

;extension=php_pdo_mysql.dll extension=php_pdo_mysql.dll 
Sign up to request clarification or add additional context in comments.

3 Comments

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
Have you restarted the web server? Maybe it doesn't use the these settings yet...
are you sure you're editing the php.ini that your script is actually using? You can check that with phpinfo()
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.