CodeIgniter Forums

Full Version: Unable to connect to your database server using the provided settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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
); 
(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.
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,