Uncaught Pdoexception error: could not find driver

Asked

Viewed 241 times

0

I’m trying to connect the sql server with php7, insert the database data into the php class, insert the extensions into the php folder in xamp, and in php.ini, but this error appears when I run the code.

My Code

$conn = new PDO ("sqlsrv:Database=dbphpsql;server=localhost\SQLEXPRESS; ConnectionPooling=0", "sa", "root");

$stmt = $conn->prepare("SELECT * FROM tb_usuarios ORDER BY deslogin");

$stmt ->execute();

$results = $stmt ->fetchAll(PDO::FETCH_ASSOC);

foreach ($results as $row) {

    foreach ($row as $key => $value) {

        echo "<strong>" . $key . ":</strong>" . $value . "<br/>";

    }

    echo "====================================================<br>";

}

var_dump($results) . "<br>";
  • Enabled the driver to sql server (PDO)?

  • Yes. I have enabled.

  • I confess I don’t know what to do.

  • Did you check if dll is in the folder and is registered in php.ini? I guess nothing appears in php.ini phpinfo() or php -m?

  • Yes, I am doing this code for an online course, I added the dll’s that made available to see which one is my pc. Extension=php_sqlsrv_71_ts_x86.dll Extension=php_sqlsrv_71_nts_x86.dll Extension=php_pdo_sqlsrv_71_ts_x86.dll Extension=php_pdo_sqlsrv_71_nts_x86.dll Extension=php_pdo_sqlsrv_71_ts_x64.dll Extension=php_sqlsrv_71_nts_x64.dll Extension=php_pdo_sqlsrv_71_nts_x64.dll Extension=php_sqlsrv_71_ts_x64.dll

  • your php is 7 or 7.1?

  • PHP version: 7.2.3

  • Can you exchange 7.2 for 7.1 or 7? in theory the 7.1 driver should be compatible with 7.2

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.