How to enable MS SQL server access in php?

The Microsoft Drivers for PHP are the PHP extensions that allows for reading and writing of SQL server data from PHP scripts. To enable it, we will need to add two extensions in PHP. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PDO for accessing data in all editions of SQL Server 2008 and later. Please follow below steps to enable it.

To check the compatible version of MS SQL drivers for your php click here.

  1. Log in to your Windows VPS via RDP (Remote Desktop Access). This tutorial will guide you to connect to Windows VPS server using the RDP from different operating systems.

  2. To download the drivers for php from click here. Select the appropriate version and click Next.

    Note: As we are using php 5.6, we have downloaded version 3.2.

    Download MS SQL Drivers For PHP

  3. It will prompt to save the exe file. Click on Save File.

    Extract Files

  4. Once the drivers are downloaded, run the exe file. It will ask for the path to extract. Provide the path and click on Ok.

    Provide Path For File Extraction

  5. Go to the extracted folder and copy the NTS (for windows) dll files to the php extension folder.

    Note: As we are using php 5.6 we have copied the files to C:\Program Files (x86)\PHP\v5.6\ext

    php_sqlsrv__56_nts.dll
    php_pdo__sqlsrv_56_nts.dll

    Copy Files to PHP Extension Folder

  6. Once the files are copied, we need to add the following extension in php.ini file.

    php_sqlsrv__56_nts.dll
    php_pdo__sqlsrv_56_nts.dll

    Add DLL Files in Php.ini

  7. Create a phpinfo file and check if the extensions are shown properly. To create phpinfo file follow instructions here.

    Check Extension sqlsrv In Phpinfo

    Check Extension pdo_sqlsrv In Phpinfo

That's it. Now you will be able to access MS SQL database from php.
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to block single IP address or range of IP addresses from Windows Firewall 2008?

Following article will assist you to block single IP address or a range of IP addresses in...

How Do I Create Multiple Reverse DNS Records On Same IP Address?

Each IP address should have single reverse DNS (rDNS). Also, your rDNS hostname should resolve...

How to allow multiple RDP sessions for the single user in Windows?

Sometimes you want to access multiple concurrent Remote Desktop sessions for the same RDP user....

How do I Increase PHP File Upload Size in Windows VPS?

Login to Windows VPS with Administrator user. Navigate to C:\Program Files (x86)\PHP\v5.X and...

How to force HTTPS from web.config file?

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create...