Codeigniter MSSQL/SQLSRV Connection

Ben picture Ben · Dec 5, 2013 · Viewed 22.8k times · Source

I'm working on a web app that connects to a MSSQL database. I previously managed to connect to the database without any problems, however I made a minor change to the sqlsrv_driver file. I encountered the below error, rolled my changes back to the original file, but there are still issues.

I have ensured that I have relevant MS drivers installed, correct port number used, etc however its returning this error:

Unable to connect to your database server using the provided settings.
Filename: D:...\system\database\DB_driver.php
Line Number: 124  

Further to this I have made a connection out side of codeigniter via the sqlsrv_connect function. Which a successful connection is made with no errors.

Why am I getting this error?

Answer

csotelo picture csotelo · Dec 5, 2013

For connection from PHP->SQLSrv you need install these drivers :

a. Microsoft Drivers 3.0 for PHP for SQL Server (SQLSRV30.EXE)

b. Microsoft Visual C++ 2010 Redistributable Package (32bits/64bits)

c. Microsoft® SQL Server® 2012 Native Client (sqlncli.msi)

And add this row in php.ini file:

extension=php_sqlsrv_54_ts.dll