PDO: could not find driver


  • | 282 points

    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 is

    PDO is available
    Array ( [0] => mysql ) .

    So what am I doing wrong/ why do I have the "could not find driver" error?


  • administrators
    | 66720 points

    @tcheulboulet : Did you enable the php_pdo_mysql.dll extension also?


  • | 282 points

    ![alt text](0_1509702623099_upload-ac3b0d71-d709-4deb-ab98-1205b01a2dc6 image url)


  • | 282 points

    The last printscreen seems to say that this extension is enabled...


  • administrators
    | 66720 points

    @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


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.