0

I have been struggling for the last three hours with the following issue and so far I can't get this to work properly.

I have an SQL Express instance running in my PC, I have checked already the port 1433 is listening by running netstat -an:

enter image description here

I am able to connect through telnet by using the following command:

telnet SQLEXPRESS 1433

This is how my database.php file looks like:

$active_group = 'mssql_common';

$db['mssql_common']['hostname'] = 'SQLEXPRESS';
$db['mssql_common']['username'] = 'ssEPA_User';
$db['mssql_common']['password'] = '**********';
$db['mssql_common']['database'] = 'ssEPA_DEV';
$db['mssql_common']['dbdriver'] = 'mssql';
$db['mssql_common']['dbprefix'] = '';
$db['mssql_common']['pconnect'] = false;
$db['mssql_common']['db_debug'] = true;
$db['mssql_common']['cache_on'] = false;
$db['mssql_common']['cachedir'] = '';
$db['mssql_common']['char_set'] = 'utf8';
$db['mssql_common']['dbcollat'] = 'utf8_general_ci';
$db['mssql_common']['swap_pre'] = '';
$db['mssql_common']['autoinit'] = true;
$db['mssql_common']['stricton'] = false;
$db['mssql_common']['port']     = 1433;

But for some reason, unknown to me, I keep getting the following error:

Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346

For the hostname setting I have tried all this combinations (one at a time):

$db['mssql_common']['hostname'] = 'SQLEXPRESS'; // instance name
$db['mssql_common']['hostname'] = 'ARX1607\SQLEXPRESS'; // pc_name\instance name
$db['mssql_common']['hostname'] = 'localhost';
$db['mssql_common']['hostname'] = '127.0.0.1';
$db['mssql_common']['hostname'] = '192.168.56.1'; // DHCP address

None of the above worked. This is driving me crazy!!!

Note: I am using Code Igniter 2.3.1 (legacy application and I can't upgrade) and PHP 5.3.3 (do not ask me why :p lol) The app is running inside a VirtualBox box using Vagrant so PHP, Apache are on the server side (guest), SQLServer is on Windows side (host).

Does any have any ideas?

I have checked a few posts here like:

And tried almost everything but use sqlsrv driver. Again, any ideas?

The mssql driver is installed and enabled see below:

enter image description here

ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • What does `` say about `mssql`> Thanks. – Zhorov Jan 28 '19 at 19:37
  • @Zhorov what do you mean? if the library is installed and enabled? if so then yes both things ... I can add that part to the OP if needed lmk. – ReynierPM Jan 28 '19 at 19:52
  • If I understand correctly, you try to connect to MS SQL using `mssql` driver. That means, that you must see `mssql` section in PHP information. – Zhorov Jan 28 '19 at 19:57
  • @Zhorov yes, I have added that information to the OP! – ReynierPM Jan 28 '19 at 20:00
  • I understand.You try to connect to MS SQL server with FreeTDS in Windows environment. I'm not familiar with FreeTDS, all my experience is with `mssql` (php_mssql.dll) and `sqlsrv` (php_sqlsrv.dll) drivers. You may try to install PHP Driver for SQL Server and try with `$db['mssql_common']['dbdriver'] = 'sqlsrv';`. Thanks. – Zhorov Jan 28 '19 at 20:33
  • Do you have `freetds.conf` file? Thanks. – Zhorov Jan 29 '19 at 07:44
  • @Zhorov I do not have such FreeTDS installed not sure what are you assuming I have on your previous comment :) – ReynierPM Jan 29 '19 at 13:56

0 Answers0