CodeIgniter Forums
Unable to connect to your database server using the provided settings - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Unable to connect to your database server using the provided settings (/thread-71883.html)



Unable to connect to your database server using the provided settings - IgniterExplorer - 10-04-2018

Hi,

I'm getting that standard error that happens when there's something wrong with the sqlsrv driver specifications.



It's php 7.1:


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

Filename: C:/.../system/database/DB_driver.php

Line Number: 436


My database.php array is

$db['default'] = array(

'dsn' => 'sqlsrvConfusederver=myserver;Database=mydatabase',

'hostname' => 'myserver',

'username' => '',

'password' => '',

'database' => 'mydatabase',

'dbdriver' => 'sqlsrv',

'dbprefix' => '',

'pconnect' => FALSE,

'db_debug' => (ENVIRONMENT !== 'production'),

'cache_on' => FALSE,

'cachedir' => '',

'char_set' => 'utf8',

'dbcollat' => 'utf8_general_ci',

'swap_pre' => '',

'encrypt' => FALSE,

'compress' => FALSE,

'stricton' => FALSE,

'failover' => array(),

'save_queries' => TRUE
);


I tried with and without the dsn specifiied.

My server is configured for Windows Authentication.  And And I'm able to connect outside of this Codeigniter project.

My thread-safe dll in extensions and php.ini is php_sqlsrv.dll


What else should I look for, in order to track this down?


RE: Unable to connect to your database server using the provided settings - qury - 10-05-2018

Hi,
This is the section from config/database.php of a project that is using sqlsrv driver.

PHP Code:
$db['mssql'] = array(
 
   'dsn'          => '',
 
   'hostname'     => 'hostname',
 
   'username'     => 'username',
 
   'password'     => 'secretpassword',
 
   'database'     => 'DATABASENAME',
 
   'dbdriver'     => 'sqlsrv',
 
   'dbprefix'     => '',
 
   'pconnect'     => FALSE,
 
   'db_debug'     => (ENVIRONMENT !== 'production'),
 
   'cache_on'     => FALSE,
 
   'cachedir'     => '',
 
   'char_set'     => 'utf8',
 
   'dbcollat'     => 'utf8_general_ci',
 
   'swap_pre'     => '',
 
   'encrypt'      => false,
 
   'compress'     => FALSE,
 
   'stricton'     => FALSE,
 
   'failover'     => array(),
 
   'save_queries' => FALSE
); 



RE: Unable to connect to your database server using the provided settings - IgniterExplorer - 10-05-2018

(10-05-2018, 04:39 AM)qury Wrote: Hi,
This is the section from config/database.php of a project that is using sqlsrv driver.

PHP Code:
$db['mssql'] = array(
 
   'dsn'          => '',
 
   'hostname'     => 'hostname',
 
   'username'     => 'username',
 
   'password'     => 'secretpassword',
 
   'database'     => 'DATABASENAME',
 
   'dbdriver'     => 'sqlsrv',
 
   'dbprefix'     => '',
 
   'pconnect'     => FALSE,
 
   'db_debug'     => (ENVIRONMENT !== 'production'),
 
   'cache_on'     => FALSE,
 
   'cachedir'     => '',
 
   'char_set'     => 'utf8',
 
   'dbcollat'     => 'utf8_general_ci',
 
   'swap_pre'     => '',
 
   'encrypt'      => false,
 
   'compress'     => FALSE,
 
   'stricton'     => FALSE,
 
   'failover'     => array(),
 
   'save_queries' => FALSE
); 

Thanks,

It's almost the same as mine, the only difference being save_queries, which I just set to FALSE.

Mine is Windows Authentication, so the userid and password aren't relevant.

I'll try and trace through to the point where the actual connection is made, and see how that compares to a known dsn.


RE: Unable to connect to your database server using the provided settings - IgniterExplorer - 10-05-2018

All set.


I just went ahead and added a Login and User, and am using that without Windows Authentication.

That's good enough for development.


Regards,