Codeigniter error when trying to connect to database using mysqli

后端 未结 10 983
陌清茗
陌清茗 2020-12-21 09:39

I am getting Following error in my CodeIgniter application which is live on server.

Here is the output of the error:

A PHP Error was encounte

10条回答
  •  时光取名叫无心
    2020-12-21 10:11

    The same error I was getting when I upload my codeigniter project from localhost to Live server.

    What solution I find is to make some changes into the application => config => database.php

    Following is the database setting for the

    localhost

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'localhost',
        'username' => 'root',
        'password' => '',
        'database' => 'creator',
        '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
    );
    

    Following database setting for

    live server (Just demo, setting differ as per hosting provider)

    1) First you have to create database.

    2) find MySql Databases(or anything related database) on dashboard,

    3) create new database and put database name, username, password.

    4) export database from localhost

    5) open phpmyadmin on live server and import it.

    6) change the setting of application=>config=>database.php by using FTP client or dashboard.

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'mysql.hostingprovider.com',    
        'username' => 'abc.username',
        'password' => 'abc.password',
        'database' => 'abc.databasename',
        '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
    );
    

提交回复
热议问题