JelleP JelleP - 5 months ago 110x
SQL Question

Connect to MS SQL on (Linux)Centos with Codeigniter

I like to connect an MS SQL database on (Linux)Centos with Codeigniter. Just installed the Centos Linux. Apache/ftp works.

But know i want to connect to an internal SQL server in my Linux machine trough Codeigniter.
I already installed with Yum mssql-php but when i trying to connect in Codeigniter it says "Unable to connect to your database server using the provided settings.".

My question is what i need to do on my Centos machine to connect my Codeigniter PHP with an internal SQL 2008 database?

My Codeigniter setting are:

$db['default']['hostname'] = '***\***,1433';
$db['default']['username'] = '***';
$db['default']['password'] = '***';
$db['default']['database'] = '**';
$db['default']['dbdriver'] = 'mssql';
$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;

On an XAMPP Windows machine this setup works well bu using sqlsrv. But that is only
supported on a Windows machine..

-- Edit --

Screen of my PHPinfo shows this:
enter image description here


It is currently working for my by installing mssql at the Linux machine. Codeigniter has the following configuration:

$db['sql']['dbdriver'] = 'mssql';

$db['sql']['dbprefix'] = '';

$db['sql']['pconnect'] = TRUE;

$db['sql']['db_debug'] = FALSE;

$db['sql']['cache_on'] = FALSE;

$db['sql']['cachedir'] = '';

$db['sql']['char_set'] = 'utf8';

$db['sql']['dbcollat'] = 'utf8_general_ci';

$db['sql']['swap_pre'] = '';

$db['sql']['autoinit'] = TRUE;

$db['sql']['stricton'] = FALSE;

PHP configuration: enter image description here

FreetDs config on Linux server

It is important to configure the connection on the Linux machine in the FreetDS config. After that you will see in the phpinfo that there is an Active connection an Codeigniter can connect with the SQL database.

enter image description here