PDO: could not find driver
-
Hello, I just tried with PDO to connect to the database and habe the "could not find driver" error.
I made following checks: php.ini has the correct dll uncommented, extension_dir is in .ini correct.
If I give a wrong database name: SQLSTATE[42000] [1049] Unknown database
If I give a wrong user name: SQLSTATE[28000] [1045] Access denied for user
If I give a wrong password: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
If the 3 values (db, user and password) are OK (meaning that I can connect to the db, right?), "could not find driver" error is displayed.With this code
<?php
if (!defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO is unavailable<br/>';
}
elseif (defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO is available<br/>';
print_r(PDO::getAvailableDrivers());?>
my output isPDO is available
Array ( [0] => mysql ) .So what am I doing wrong/ why do I have the "could not find driver" error?
-
@tcheulboulet : Did you enable the php_pdo_mysql.dll extension also?
-

-
The last printscreen seems to say that this extension is enabled...
-
@tcheulboulet : Yes, I see you enabled them. So, it is not because of your settings. You can check this: https://stackoverflow.com/questions/42848062/php-could-not-find-driver-pdo-mysql