Enable MS SQL server access in php

kumkumsharma

Administrator
Staff member
To access MSSQL server data from PHP scripts you will need to enable two php extensions SQLSRV extension and PDO_SQLSRV extension. You can follow below steps to enable these extensiosn in SQL server 2008.

First of all you have to check the compatible version of MSSQL drivers with your PHP, you can check.
  • Login to Windows VPS
  • You can download the PHP drivers from here and then click on “Next”.
  • Here we are using PHP 5.6 version so we have downloaded version 3.2.
  • This will help to save the exe file and now click on “Save” file.
  • After downloading th drivers run the exe file and provide proper path to extract it and clickon “Ok”.
  • Navigate to extracted folder and copy windows dll files to php extension folder.
For example, if we are using php 5.6 so we have to copy files to C:\Program Files (x86)\PHP\v5.6\ext location.
Code:
php_sqlsrv__56_nts.dll
php_pdo__sqlsrv_56_nts.dll
  • After coping files, now its time to add below extension in php.ini file.
Code:
php_sqlsrv__56_nts.dll
php_pdo__sqlsrv_56_nts.dll
  • To check the extensions are enabled or not, we have to create phpinfo file and then search for extensions in file.
 
Top