PDO Installation
Posted: Sun Jun 18, 2006 7:11 am
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:
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:
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.
Code: Select all
extension=php_pdo.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dllCode: Select all
try
{
$db = new PDO('mysql:host=localhost;dbname=circus_arts_db', 'user', 'pass');
} catch (Exception $e)
{
echo $e->getMessage();
}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.