无法使用提供的设置连接到数据库我的错误

时间:2019-05-10 07:28:13

标签: codeigniter phpmyadmin

我有这个由php和mysql创建的项目,但是我有错误

文件名:C:\ xampp \ htdocs \ demo \ system \ database \ DB_driver.php

行号:124

并上传了我的项目来解决这个问题,非常感谢所有团队。

http://www.webchinupload.com/f/2019-05/ebae9eaf2a9655eb442da8a9e648da3e.rar

我在第124行中的错误

$this->conn_id = ($this->pconnect == false) ? $this->db_connect() : $this->db_pconnect();

    // No connection resource?  Throw an error
    if ( ! $this->conn_id)
    {
        log_message('error', 'Unable to connect to the database');

        if ($this->db_debug)
        {
            $this->display_error('db_unable_to_connect');
        }
        return FALSE;
    }

2 个答案:

答案 0 :(得分:0)

hostname更改为localhost

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = ''; #database password
$db['default']['database'] = 'e-frosh_test';

答案 1 :(得分:0)

检查您的application / config / database.php

在codeigniter框架中

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => 'root',//Put Your db passwaord
    'database' => 'e-frosh_test',
    '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
);