CodeIgniter Forums
sqlsrv_connect() problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: sqlsrv_connect() problem (/showthread.php?tid=1621)



sqlsrv_connect() problem - microchip - 03-26-2015

I'm trying to get CI3 connecting to SQL server on a Windows 2012 R2 box.

I get the same error whether I use the sqlsrv or mssql driver specification in the database.php file.
The error complains that sql_connect or mssql_connect is undefined in the sql_driver.php file (or mssql_driver.php)

Has anyone come across this problem?


RE: sqlsrv_connect() problem - mwhitney - 03-26-2015

It sounds like you need to install the PHP sqlsrv driver. Documentation for installation/configuration is at http://php.net/manual/en/book.sqlsrv.php


RE: sqlsrv_connect() problem - microchip - 03-27-2015

Thanks mrwhitney, but I have the latest Microsoft PHP driver for SQL installed. Whether it is in the right place is another matter as the docs say put it in the extensions folder php/extensions but it is actually named /ext.


RE: sqlsrv_connect() problem - mwhitney - 03-27-2015

If sqlsrv_connect is not defined, the Microsoft driver is either not installed or not loading properly. The function is provided by the Microsoft driver.

The same goes for mssql_connect, except that it is a command provided by a completely different driver which is not available in more recent versions of PHP anyway.

Microsoft's documentation for the sqlsrv driver includes information on configuring it to load when PHP starts and confirming that it is loading properly in your environment: https://msdn.microsoft.com/en-us/library/cc296203%28v=sql.105%29.aspx


RE: sqlsrv_connect() problem - umittas2000 - 01-26-2016

Hello,

I had same problem with following configuration,  

* Windows 8, 64bit
* SQLSRV30.exe ( which is containing SQL Server php DLL files )
*sqlncli.msi
* WAMP with 64 bit & PHP 5.5
* CodeIgniter 3.0.4
* SQL Server 2012 standard ( & Tested SQL Server 2014 express too )

and I fixed it with following configuration

* Remove WAMP 64 bit & Install 32 bit WAMP
* Install sqlncli.msi
* extract SQLSRV30.exe in somewhere in your pc
* in SQLSRV30 extracted files, find & copy php_sqlsrv_55_ts.dll  & php_pdo_sqlsrv_55_ts.dll in to WAMP\bin\PHP5.5.12\ext\
*register that 2 files into php.ini files which is in WAMP\bin\PHP5.5.12\
*Fully close WAMP & re-open again ( don't restart service , fully close from system tray right click/ exit )

It's solved my problem, it caused because of SQL server PHP drivers not running on 64 bit WAMP.