I'm working on a web project that is to be deployed on a 64bit Windows 2008 Server machine running IIS 7.5 and PHP 5.3.8. The database on the system is Microsoft SQL Server 2008 R2. I'm developing the application on the CodeIgniter 2.1.0 framework, and I'm a bit stumped on getting it to connect to the SQL Server.
I've tried using both the MSSQL, ODBC and SQLSRV database drivers, and have encountered three separate errors, for each different driver.
Here is my configuration for ODBC:
$db['default']['hostname'] = 'SA';
$db['default']['username'] = 'petre';
$db['default']['password'] = 'start';
$db['default']['database'] = 'petre';
$db['default']['dbdriver'] = 'odbc';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
I have the DNS for SA defined under Data Sources, and I'm sure that the username and password are both valid, and that the server accepts Mixed authentication(Windows + SQL authentication).
I'm auto-loading the DB library and for any page I access I get:
Unable to connect to your database server using the provided settings.
Filename: C:inetpubwwwrootsystemdatabaseDB_driver.php
Line Number: 124
If I try to connect via MSSQL, I just get a blank page, no matter what.
If I try using SQLSRV using the following params:
$db['default']['hostname'] = '127.0.0.1';
$db['default']['username'] = 'petre';
$db['default']['password'] = 'start';
$db['default']['database'] = 'petre';
$db['default']['dbdriver'] = 'sqlsrv';
Even though I'm linking to the sqlsrv DLL file in php.ini, I get the following message:
PHP Fatal error: Call to undefined function sqlsrv_connect() in C:inetpubwwwrootsystemdatabasedriverssqlsrvsqlsrv_driver.php on line 76
I've been reading up on old posts and different views but I've yet to solve the problem.
I'm only looking for a solution for a single DB Driver - anything that gets it to connect is fine. Does anyone have any advice on solving this?
See Question&Answers more detail:
os