2
votes

I have installed Xampp and Codeigniter. Now I want to connect to a SQL database. I have installed the sqlsrv drivers on Xampp, so that works. I also fixed a bug in the sqlsrv_driver.php and changed this:

function db_pconnect()
{
    // $this->db_connect(TRUE); original
    return $this->db_connect(TRUE);
}

This is my config file:

$db['default']['hostname'] = 'ipAddress\instanceName';
$db['default']['username'] = 'xxx';
$db['default']['password'] = 'xxx';
$db['default']['database'] = 'xxx';
$db['default']['dbdriver'] = 'sqlsrv';
$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 following error:

Unable to connect to your database server using the provided settings.

Filename: C:\xampp\htdocs\system\database\DB_driver.php

Line Number: 124

I had some errors with sqlsrv before, but I solved it by the answers on this question:

Connect sqlsrv in Xampp

1
I wouldn't even use codeigniter. As we speak right now I'm having to add a feature to a codeigniter project and I - Tim Lieberman
Why shouldn't I use CodeIgniter? It is an existing project, so I don't have a choice. - Marten
You can use Codeingiter for SQL connect but your webserver do need an SQL driver.. - JelleP
CodeIgniter is outdated. You'd better use Laravel. ;) - Gerard de Visser

1 Answers

1
votes

there is an error with your hostname try to use

$db['development_local']['hostname'] = 'localhost';