I can not create the connection to the bank in my php file

0

I'm trying to connect to the bank but only this error appears:

  

Fatal error: Uncaught PDOException: could not find driver in   C: \ xampp \ htdocs \ PDO \ Example-02.php: 3 Stack trace: # 0   C: \ xampp \ htdocs \ PDO \ Example-02.php (3):   PDO- > __ construct ('sqlsrv: Database ...', 'user', 'password') # 1 {main}   thrown in C: \ xampp \ htdocs \ PDO \ Example-02.php on line 3

I have already downloaded the necessary drivers for php but it did not work. Follow the code (it's just a simple code to test if you're connecting)

<?php
$conn = new PDO( "sqlsrv:Database=db1;server=localhost\SQLEXPRESS;ConnectionPooling=0","usuario", "senha"); 

$stmt = $conn->prepare("INSERT INTO usuario(id, nome) VALUES(1,'Eddy')");

$stmt->execute();
?>

The following are the drivers used:

extension=php_pdo_sqlsrv_71_nts_x64.dll

extension=php_pdo_sqlsrv_71_nts_x86.dll

extension=php_pdo_sqlsrv_71_ts_x64.dll

extension=php_pdo_sqlsrv_71_ts_x86.dll

extension=php_sqlsrv_71_nts_x64.dll

extension=php_sqlsrv_71_nts_x86.dll

extension=php_sqlsrv_71_ts_x64.dll

extension=php_sqlsrv_71_ts_x86.dll

I will be very grateful if you can help me, I have been trying to resolve this for a while.

    
asked by anonymous 13.01.2018 / 23:28

1 answer

1

I had the same problem as you. Fix it by adding in the php.ini extensions, I restarted the WampServer (I'm using this in place of Xamp ) and worked correctly.

Another thing I did was to just leave dll from x64 because it would not use x86 . I hope I have helped.

    
04.06.2018 / 20:25