Monday, March 30, 2015

Accessing MSSQL with PHP - Solving Microsoft ODBC Driver Problem

I'm using PHP 5.6.3 with XAMPP (installed using xampp-win32-5.6.3-0-VC11-installer.exe). When trying to connect to MSSQL server database, it trigger error as below (or almost the same error).

Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server....

This error occur after the XAMPP started with sqlserver extension defined in PHP.ini successfully loaded.

Looking at PHP manual @ only shows how to connect. A few more site shares the same things too:


Even going to Microsoft MSDN won't help that much.

So, I would like to share the step that you should take if you found or getting the same error:
  1. Go to will share the necessary steps and it is really good if you could start from this point forward.
  2. Then, download Microsoft ODBC Driver 11 from Microsoft. Please make sure you select the correct SQL Server version. I'm using SQL Server 2014 and therefore is using the driver from that link. You may used different version of ODBC driver. It also dependent on OS architecture (x86 or x64).
  3. Upon complete this two steps, you should already have 
    • SQLSRV32.exe or SQLSRV30.exe
    • vcredist_x64.exe or vcredist_x86.exe
    • sqlncli.msi
    • msodbcsql.msi
  4. Installed one by one according to the list (from top to bottom). If you already installed, please ignore the file.

My problem of connecting the SQLSERVER in PHP resolved after I've installed all file.

That's all...

Happy PHPing


Share It

Popular Posts