I am working on a web project that will be deployed on a 64-bit machine running Windows 2008 Server with IIS 7.5 and PHP 5.3.8. The database in the system is Microsoft SQL Server 2008 R2. I am developing an application on the CodeIgniter 2.1.0 platform, and I am a little fixated on connecting to SQL Server.
I tried using the MSSQL, ODBC, and SQLSRV database drivers and ran into three separate errors for each other 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 in Data Sources, and I am sure that the username and password are valid and that the server accepts mixed authentication (Windows + SQL authentication).
I automatically load the database library and for any page that I get:
Unable to connect to your database server using the provided settings. Filename: C:\inetpub\wwwroot\system\database\DB_driver.php Line Number: 124
If I try to connect via MSSQL, I just get a blank page, no matter what.
If I try to use SQLSRV using the following parameters:
$db['default']['hostname'] = '127.0.0.1'; $db['default']['username'] = 'petre'; $db['default']['password'] = 'start'; $db['default']['database'] = 'petre'; $db['default']['dbdriver'] = 'sqlsrv';
Even if I contact the sqlsrv dll file in php.ini, I get the following message:
PHP Fatal error: Call to undefined function sqlsrv_connect() in C:\inetpub\wwwroot\system\database\drivers\sqlsrv\sqlsrv_driver.php on line 76
I read old posts and different opinions, but I have not solved the problem yet.
I am looking for a solution for only one DB driver - everything that gets it to connect is fine. Does anyone have any tips for resolving it?