简体   繁体   中英

Cannot connect to SQL SERVER database using codeigniter

This is my database.php (I am using XAMPP and CODEIGNITER). I cannot connect to a SQLSERVER database (it is a mess)

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'SER054USA',//server_name
    'username' => 'admin',
    'password' => '45645sfd45',
    'database' => 'PROD',
    'dbdriver' => 'mysqli',
    '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 got this error massage:

No connection could be made because the target machine actively refused it

I have tried so many times but i was not able to solve this.

I have searched a lot, seen several threads but no one really helped me.

Your database driver is wrong. mysqli is for mysql

Tou need to set your driver to sqlsrv

To install that, please go to https://www.microsoft.com/en-us/download/details.aspx?id=20098 and get the driver for your appropiate php version. Once you installed it for your version of XAMPP, enable it, and set sqlsrv in your database config file

Restart apache and you should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM