• 1-888-289-2246
  • 24x7x365 Presence

Connecting PHP with the MSSQL database on IIS7


Sometimes we have to connect PHP with MSSQL – most of the webhosts don’t offer this on a shared environment but it is possible to have this facility on a dedicated server or VPS with the following steps:-

Step 1: Make sure that you’re running the IIS web server with PHP installed on it.

Step 2: Download Microsoft Drivers 3.0 for PHP and the SQL Server on your server and run the file:-

http://www.microsoft.com/en-in/download/details.aspx?id=20098

Step 3: When prompted, enter the path to the PHP extensions directory – it’s recommended by Microsoft to use ‘C:\Program Files’

Step 4: After extracting the files, copy the dlls from the extracted directory

————————————–
(For non-thread safe)
php_pdo_sqlsrv_53_nts.dll
php_sqlsrv_53_nts.dll

(For thread safe)
php_sqlsrv_53_ts.dll
php_pdo_sqlsrv_53_ts.dll
————————————–

to the PHP extensions directory which could be like C:\PHP\ext\ or ‘C:\Program Files x86\PHP\ext\’ on the server.

Note: Read the Installation section of the SQLSRV30_Readme.htm file for more details.

Step 5: Install the Microsoft SQL Server native client as per your MSSQL edition – 2005 or 2008 or 2012.

Step 6: Enable the sqlsrv extension in the php.ini configuration file of the server, as below:-

extension=php_sqlsrv_53_nts.dll
extension=php_pdo_sqlsrv_53_nts.dll

Step 7: Then restart the web service or IISRESTART on the server, and then check the phpinfo page and you should be seeing that the sqlsrv section is now being displayed on that page which means that you are now able to connect with the MSSQL database using PHP code.

That’s all.

]]>


Leave a Reply

Your email address will not be published. Required fields are marked *