Answer the question
In order to leave comments, you need to log in
How to setup connection to ms sql via PDO class?
I do this $DBH = new PDO("mssql:host=localhost;dbname=health", $user, $pass);
in response I get only
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in D:\Projects\ZInfo\ZInfo-App-IsraelDieta\htdocs\site.ru\index2.php:5 Stack trace: #0 D:\Projects\ZInfo\ZInfo-App-IsraelDieta\htdocs\site.ru\index2.php(5): PDO->__construct('mssql:host=SIRI...', '-----', '------...') #1 {main} thrown in D:\Projects\ZInfo\ZInfo-App-IsraelDieta\htdocs\site.ru\index2.php on line 5
Answer the question
In order to leave comments, you need to log in
If you are on Windows (judging by the paths), then you need to install SQL Server Native Client x64 or x86 , depending on the platform. Then install the sqlsrv driver itself (do not forget to read the README, where it says which version of php which extension to connect to).
Then use the following as your DSN:
$dsn = 'sqlsrv:server=your-sqlserver-host.com;Database=db_name';
$pdo = new PDO($dsn, $username, $password);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question