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

[版本 2.x] 数据库连接问题求解:A Database Error Occurred

[复制链接]
发表于 2011-10-14 17:04:31 | 显示全部楼层 |阅读模式
$autoload['libraries'] = array('database', 'session');

$db['default']['hostname'] = '127.0.0.1';
$db['default']['port']            = "3306";
$db['default']['username'] = 'root';
$db['default']['password'] = 'mysql.aaaa.com';
$db['default']['database'] = '51cvs';
$db['default']['dbdriver'] = 'mysql';
$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'] = FALSE;
$db['default']['stricton'] = FALSE;

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: /var/www/htdocs/oa.aaa.com/models/adminuser_model.php

Line Number: 14

adminuser_model.php:
$sql = sprintf("select * from admin_user where username='%s' and password='%s'", $username, md5($password));
                $query = $this->db->query($sql);
                $adminuser = array();
                if ($query->num_rows() > 0)
                {
                   $adminuser = $query->row();
                }
                return $adminuser;
 楼主| 发表于 2011-10-14 17:05:13 | 显示全部楼层
求解啊。
 楼主| 发表于 2011-10-14 17:05:37 | 显示全部楼层
坛子里有类似问题,但是试了都没用。
 楼主| 发表于 2011-10-14 17:40:10 | 显示全部楼层
解决了:$db['default']['hostname'] = '127.0.0.1';=>$db['default']['hostname'] = 'localhost';

本版积分规则