Page 1 of 1

PDO Installation

Posted: Sun Jun 18, 2006 7:11 am
by Ree
I have a problem installing PDO drivers for PHP 5.1.4 on Windows XP. I have followed the instructions here and added the following in my php.ini:

Code: Select all

extension=php_pdo.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
PHP seems to find the PDO extension itself, but not the drivers. Under PDO section PDO Drivers has no value and obviously when trying to use PDO in code I get the 'could not find driver' exception:

Code: Select all

try
{
  $db = new PDO('mysql:host=localhost;dbname=circus_arts_db', 'user', 'pass');
} catch (Exception $e)
{
  echo $e->getMessage();
}
Any clues why this is happening? I double checked the dlls and they are available in the extension directory.

Solution: For MySQL and MS SQL to be available with PDO you need to copy libmysql.dll and ntwdblib.dll into your <windows root>\system32\ directory. Actually, I'm surprised this is not documented on PDO page.

Posted: Sun Jun 18, 2006 11:31 am
by jmut

Code: Select all

<?php
print_r(PDO::getAvailableDrivers());
?>
What is this returning?

Posted: Sun Jun 18, 2006 3:13 pm
by Ree
An empty array of course.