4

I've checked the php.ini file the extensions are enabled:

extension=php_pdf.dll extension=php_pdo.dll extension=php_pdo_firebird.dll extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll 

but still when i try to open the page it gives the error

500 | Internal Server Error | PropelException Unable to open PDO connection [wrapped: could not find driver]

what do i need to do now? to eliminate this error

thanks

4
  • First of all you should post the code that's causing the trouble. Commented Apr 7, 2009 at 9:16
  • well i am new to symfony all i did was php symfony propel-generate-crud frontend post Post and tried to open localhost/sf_sandbox/web/frontend_dev.php/post Commented Apr 7, 2009 at 9:25
  • check if php_pdo_mysql.dll is there in your [phpinst]/ext directiory Commented Nov 25, 2014 at 5:21
  • run php --ini and see if there's an extension missing. If so, open your php.ini and see if the path to extensions is correct. Look for extension_dir Commented Jun 19, 2016 at 18:11

5 Answers 5

2
  • Find out which PDO driver you actually need (MySQL, MS SQL...?)

  • Test by instantiating PDO yourself, to avoid errors elsewhere:

    $db = new PDO('mysql:host=127.0.0.1;dbname=testdb', 'username', 'password');

If you still get "could not find driver", now you can be sure that you're really missing it :)

How to install it, if you don't have it already, depends a lot on your system. On Debian Linux, for example, you need to do apt-get install php5-mysql, which installs mysql, mysqli and pdo_mysql extensions.

After you install it, ensure that it's enabled in php.ini. make sure that you're editing the correct file - the one that is used by your webserver.

Afterwards, to verify the extension was loaded correctly, either:

  • create a script which executes phpinfo(). You should see a PDO section with a key PDO drivers and a value such as "mysql, pgsql", or

  • run php -m from the command line and you should see pdo_mysql for example.

Sign up to request clarification or add additional context in comments.

Comments

1

The php_pdo_mysql.dll in the extension directory may be trying to load the libmysql.dll or mysql.dll which by default is in the php directory (I think - they are at least in my php directory but I installed it so long ago I can't remember if they were there by default or if I copied them there). If the php directory is not in your PATH these latter dll's will not be found and cause the error.

I would suggest checking that the libmysql.dll and/or mysql.dll is in your php directory. If so, add your php directory to your system's PATH and REBOOT your computer. I had the same problem, added the php directory to the system's path, restarted Apache and the problem wasn't solved. I needed to reboot before Apache/PHP would find the dll's in the php directory.

An alternative is to copy libmysql.dll and mysql.dll into a directory that is searched by default (is it the Windows directory or maybe the Window\System32 directory). When the php_pdo_mysql.dll is loaded it will then be able to find the dependent dlls.

If these two dlls aren't in your php directory, try downloading and installing MySQL. You may find these dlls in amongst the files installed my the MySQL installer.

If you're using Apache it should be reporting in the error log that it can't load php_pdo_mysql.dll. If not, maybe it's reporting some other error on start up. Posting any errors from the log maybe helpful for diagnosis.

Hope this helps.

Comments

0

In php.ini set the following to check if there's a problem loading the extensions.

display_startup_errors = On 

Comments

0
  • I've had problems in the past where despite the DLL being in the php/ext/ directory and despite the php path being set properly, I had to specify the absolute path to the extension.

  • Check the Apache error logs to see if there was a problem loading the extension

Comments

0

Are you working with the Command line?

Often the command line and the PHP in the browser use different PHP.ini files.

Use phpinfo() to check the modules included on the borwser Use PHP -m to see the modules installed via the CLI

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.