I want to connect to SQL Server at another pc with php, when i try to connect it says
Connection error: could not find driver
What I have tried is add extension in php.ini
.
;extension=php_sqlsrv_56_ts.dll
extension=php_pdo_sqlsrv_72_ts_x64.dll
extension=php_sqlsrv_72_ts_x64.dll
- my PHP version is: 7.2.3
- SQL SERVER: SQL Server 2014
- OS PC: Windows Server 2012 R2 (another pc)
here's my code:
<?php
$host = "192.168.3.126";
$db_name = "dbo";
$username = "david";
$password = "david";
try {
//$con = new PDO("mysql:host={$host};dbname={$db_name}", $username, $password);
$db = new PDO("sqlsrv:Server={$host};Database={$db_name}", $username, $password);
}
catch(PDOException $exception){ echo "Connection error: " . $exception->getMessage();}
?>
NB: I have download Microsoft Drivers 5.6 for PHP for SQL Server
at here, I have download install the ODBC Driver 17 at my own pc
I have tried this reference but it doesn't work PHP Sql Server PDOException:could not find driver