Wednesday, December 15, 2010

Wamp + MSSQL

I've tried a lot of things just to connect MSSQL with PHP and I've come up with this solution. Parts of this tutorial has been gathered from other forums.

1. Download and install the following files from
- wampserver2.0i
- apache 2.2.8 (Add On)
 - php 5.2.6 (Add On)

2. ntwdblib.dll (version 2000.80.194.0)
- download from or if it's not available anymore you can contact me and I'll send you the copy.
- stop all Wamp Services and SQL Server service
- copy and replace this file to 
1. ie: C:\wamp\bin\php\php5.2.6 
2. ie: C:\wamp\bin\apache\apache2.2.8\bin 
3. ie: C:\Windows\System32\ 

4. Enable apache and php version from wamp server

5. Activate php_mssql from PHP extensions

6. Configure SQL Server to accept TCP connections and Named Pipes through the SQL server configuration manager. 

7. Configure SQL Server for Mixed mode authentication and remember the password you set for sa 

8. Start the SQL Server Service 

9. Enable mssql.secure_connection = On (can be found at php.ini)
- Note that if you are not using NT authentication then you can turn it Off.

10. Start WampServer

11. Enable PHP 5.2.6 and Apache 2.2.8

12. Test connection
$conn = mssql_connect('SQLSERVER','USER','PASSWORD'); 
if ($conn){
echo 'Connected';