0

This is the error:

An Error Was Encountered. Invalid DB driver

I am using CodeIgniter 3.1.9 framework for a website and I am on the process of connecting the database I imported on HeidiSQL to the framework.

To connect to the database, I decided to install sql server drivers for the specific php version I have (PHP 7.2.9). By the way, I have Microsoft SQL Server 2012 Native Client installed and my operative system is a Windows 7 Professional 64 bits.

I created a folder inside CodeIgniter named 'sqlsrv' and installed the drivers inside.

I configured php.ini file like this, adding the extensions needed:

extension=sqlsrv
extension=php_sqlsrv.dll
extension=php_sqlsrv_72_ts_x64.dll
extension=php_sqlsrv_72_ts_x86.dll
extension=php_pdo_sqlsrv_72_ts_x64.dll
extension=php_pdo_sqlsrv_72_ts_x86.dll
extension=php_pdo.dll

And here is the database.php configuration file (server/hostname, port, username, database/dbname and password values are not real for safety):

$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
    'dsn'   => 'Driver={SQL Server 2012 Native Client};server=192.168.7.88;port=1422;dbname=database_name;username=user_name;password=pass',
    'hostname' => '192.168.7.88', 
    'username' => 'user_name', 
    'password' => 'pass', 
    'database' => 'database_name', 
    'dbdriver' => 'sqlsrv', 
    'dbprefix' => '',
    'pconnect' => FALSE, 
    'db_debug' => TRUE ,
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'autoinit' => TRUE, 
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

);

I tried changing the content inside 'dsn' value and leaving it empty, enabling more sql server drivers and infinite other ways like using odb (not useful because query builder is not allowed) alternatively and it's still not working.

2
  • try the pdo variant - something like 'dsn' => 'sqlsrv:server=192.168.7.88,1422;Database=database_name' and your driver should be 'dbdriver' => 'pdo' Commented Sep 26, 2018 at 12:50
  • Possible duplicate of How do I connect to a SQL Server database in CodeIgniter? Commented Sep 27, 2018 at 4:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.