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)?
– rray
Yes. I have enabled.
– Leonardo
I confess I don’t know what to do.
– Leonardo
Did you check if dll is in the folder and is registered in php.ini? I guess nothing appears in php.ini
phpinfo()
orphp -m
?– rray
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
– Leonardo
your php is 7 or 7.1?
– rray
PHP version: 7.2.3
– Leonardo
Can you exchange 7.2 for 7.1 or 7? in theory the 7.1 driver should be compatible with 7.2
– rray