用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1943|回复: 2
收起左侧

[已解决] A Database Error Occurred (sqlsrv)

[复制链接]
发表于 2015-1-6 15:03:40 | 显示全部楼层 |阅读模式
本帖最后由 Closer 于 2015-1-6 15:24 编辑

Unable to connect to your database server using the provided settings.
Filename: C:\webroot\CodeIgniter\system\database\DB_driver.php
Line Number: 124

以上是问题内容。
我又用代码调试发现:
A PHP Error was encounteredSeverity: 4096
Message:  Argument 2 passed to sqlsrv_connect() must be of the type array, string given, called in C:\webroot\CodeIgniter\system\database\DB.php on line 41 and defined
Filename: config/database.php
Line Number: 79
以一下是我的database.php的配置
$db['default']['hostname'] = '192.168.8.120,1433';
$db['default']['username'] = 'tx002';
$db['default']['password'] = 'tx002';
$db['default']['database'] = 'ENVI';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;


发表于 2015-1-6 15:16:54 | 显示全部楼层
本帖最后由 Closer 于 2015-1-6 15:20 编辑

第一次看到這種配置
$db['default']['hostname'] = '192.168.8.120,1433';

hostname 有支持獲取兩個參數?



抱歉,見識淺薄,讓你見笑了
sqlsrv 都這樣用

 
 楼主| 发表于 2015-1-6 15:29:09 | 显示全部楼层
呵呵 这个问题我已经解决了,在database.php中
$db['default']['pconnect'] = TRUE;
将这个改为false就可以了

本版积分规则