无法将SQL Server与Codeigniter连接

时间:2018-09-04 08:41:49

标签: php codeigniter

我开发了具有SQL Server连接的Codeigniter应用程序。在Windows 7 PC上使用PHP 5.6时,它已正确连接,但同一应用程序在具有相同PHP版本的Windows 10上无法正常工作。显示错误enter image description here

$db['default'] = array(
'dsn'   => '',
'hostname' => '192.168.0.241',
'username' => 'sa',
'password' => 'mypw',
'database' => 'dbsrver',
'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

);

1 个答案:

答案 0 :(得分:0)

您可能在配置中有一些错误。确保您已正确配置数据库。 在application / config / databse.php

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => 'write password if any otherwise leave it empty',
    'database' => 'Your_Database_Name',
    '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
);