0

I have the following conf database

$db['default']['hostname'] = 'xx.xx.xx.xx,1433';
$db['default']['username'] = 'user';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'dbname';
$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;

Codeigniter get me the Unable to connect to database using the parameters entered...what's wrong? i try the following connection for $db['default']['hostname']

$db['default']['hostname'] = 'xx.xx.xx.xx,1433';
$db['default']['hostname'] = '(xx.xx.xx.xx),1433';
$db['default']['hostname'] = 'xx.xx.xx.xx:1433';

and it don't work Any ideas? Thanks

ocrama
  • 31
  • 2
  • 9

2 Answers2

2

Set

$db['default']['pconnect'] = false;

That should work.

anar khalilov
  • 16,993
  • 9
  • 47
  • 62
0

You added hostname and port number together codeigniter has a setting to define port number

$db['default']['hostname'] = 'xx.xx.xx.xx';
$db['default']['username'] = 'user';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'dbname';
$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;
$db['default']['port'] = 1433;

For more details go to http://ellislab.com/codeigniter/user-guide/database/configuration.html

ARIF MAHMUD RANA
  • 5,026
  • 3
  • 31
  • 58
  • I have inserted the following line $db['default']['port'] = 1433; Now my database conf is exactly as you post me. But still don't work the error is the same: "A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: C:\wamp\www\myssite\system\database\DB_driver.php Line Number: 124" – ocrama Sep 10 '13 at 11:30
  • @ocrama check this http://stackoverflow.com/questions/8669337/codeigniter-mssql-connection/13433923 do you have sql server extension for php ? Also, do you have the SQL Server Native Access Client (SNAC) 10 installed ? – ARIF MAHMUD RANA Sep 10 '13 at 11:55
  • @ocrama also check this one http://ellislab.com/forums/viewthread/208171/#1017407 – ARIF MAHMUD RANA Sep 10 '13 at 11:58
  • i'm using WAMP server and i have all the extension for sqlsrv: it appear in my phpinfo. i also have SQL Server Native Access Client (SNAC) 10 because in the same machine i have installed sql server management studio. The problem is maybe WAMP? – ocrama Sep 10 '13 at 13:47
  • Alternatively, in Ubuntu is possibile to make work Codeigniter with sqlsrv? – ocrama Sep 10 '13 at 15:52