How to connect sql server with php using xampp?

Sahil Verma picture Sahil Verma · Dec 7, 2018 · Viewed 15.4k times · Source

I am trying to connect my SQL server with PHP using Xampp. I have already uploaded dll files in the ext folder but I am unable to connect it. My PHP version is 7.2.6. Uploaded dll files are - php_pdo_sqlsrv_72_ts.dll, php_sqlsrv_72_ts.dll. I have written this code to connect my SQL database with PHP-

I am getting this error when I had tried this-

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\biometric\db.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\biometric\db.php on line 7.

Anyone has an idea where I am doing wrong or how to connect with the database.

Answer

Zhorov picture Zhorov · Dec 8, 2018

Installation of PHP Driver for SQL Server (sqlsrv and/or pdo_sqlsrv PHP extensions) can be done following the next steps:

Check the configuration with <?php phpinfo();?>. There should be a section with name pdo_sqlsrv (if you use PDO) and/or sqlsrv (without PDO).