0
I’m trying to connect with the bank but only appears this error:
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 already downloaded the drivers needed for php but it didn’t help. Follow the code (it’s just a simple code to test if you can connect)
<?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();
?>
Also follow 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’ll be very grateful if you can help me, I’ve been trying to figure this out for a while.
What is your version of PHP? 7.1? and you only need to use one driver. x86 for 32-bit and x64 for 64-bit architecture, also see https://answall.com/a/130889/45722 to see if you need nts or ts
– user45722
My php is 7.1.
– user8180590
You added all drivers on
php.ini
?– user45722
Yes I added.
– user8180590
What is your computer’s architecture? 32-bit or 64-bit?
– user45722
is 64 , so I’ve already put only the 64 drive, have to put in the ext folder ? and then add in php.ini, I’ve already done this and it still makes the same mistake of not finding the drives
– user8180590
Yes, you add it to the folder
ext/
. Just try to add:extension=php_pdo_sqlsrv_71_nts_x64.dll
– user45722
if it doesn’t work, try
extension=php_pdo_sqlsrv_71_ts_x64.dll
. Of course they need to be in the folder.– user45722
hasn’t worked yet .
– user8180590
Here’s the code with the la part in php.ini
– user8180590
; Be sure to appropriately set the extension_dir Directive. --> Extension=php_pdo_sqlsrv_71_ts_x64 <- Extension=bz2 Extension=Curl Extension=fileinfo
– user8180590
I did the following uninstalled php and installed 7.2, now I will have to download other drives or these serve?
– user8180590
It’s been a long time since I’ve dealt with PHP, but it’s very likely that you won’t be able to use SQL Server, because the extension is for version 7.1 and it’s not for 7.2 yet. If you find 7.2 drivers, try using them.
– user45722
Okay, thanks for the help.
– user8180590