CodeIgniter Forums
Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given (/showthread.php?tid=1442)



Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - anonprophet - 03-10-2015

i got the message

Code:
Severity: Warning

Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given

Filename: mysqli/mysqli_driver.php

Line Number: 316

im connect to 3 different database with different server too

PHP Code:
$active_group 'default';
$active_record TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'app';
$db['default']['dbdriver'] = 'mysqli';
$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;

/* Dota Statistic Database Configuration */

$db['stats']['hostname'] = '49.128.182.xxx';
$db['stats']['username'] = 'xxx';
$db['stats']['password'] = 'xxx';
$db['stats']['database'] = 'anonstats';
$db['stats']['dbdriver'] = 'mysqli';
$db['stats']['dbprefix'] = '';
$db['stats']['pconnect'] = FALSE;
$db['stats']['db_debug'] = FALSE;
$db['stats']['cache_on'] = TRUE;
$db['stats']['cachedir'] = '';
$db['stats']['char_set'] = 'utf8';
$db['stats']['dbcollat'] = 'utf8_general_ci';
$db['stats']['swap_pre'] = '';
$db['stats']['autoinit'] = FALSE;
$db['stats']['stricton'] = FALSE;

/* PvPGN Database Configuration */

$db['pvpgn']['hostname'] = '49.128.182.xxx';
$db['pvpgn']['username'] = 'xxx';
$db['pvpgn']['password'] = 'xxx';
$db['pvpgn']['database'] = 'pvpgn';
$db['pvpgn']['dbdriver'] = 'mysqli';
$db['pvpgn']['dbprefix'] = '';
$db['pvpgn']['pconnect'] = TRUE;
$db['pvpgn']['db_debug'] = FALSE;
$db['pvpgn']['cache_on'] = FALSE;
$db['pvpgn']['cachedir'] = '';
$db['pvpgn']['char_set'] = 'utf8';
$db['pvpgn']['dbcollat'] = 'utf8_general_ci';
$db['pvpgn']['swap_pre'] = '';
$db['pvpgn']['autoinit'] = FALSE;
$db['pvpgn']['stricton'] = FALSE

im try to call model function username_exist

PHP Code:
class Pvpgn extends CI_Model {

    private 
$pvpgn;
    private 
$app;

    public function 
__construct()
    {
        
parent::__construct();
        
$this->pvpgn $this->load->database('pvpgn',TRUE);
        
$this->app $this->load->database('default',TRUE);
    }

    public function 
username_exist($username)
    {
        
$this->app->select('id');
        
$this->app->where('username'$username);
        
$query $this->app->get('member');

        if (
$query->num_rows() == 1) {
            return 
true;
        } else {
            
$this->pvpgn->select('uid');
            
$this->pvpgn->where('acct_username'$username);
            
$qry $this->pvpgn->get('pvpgn_BNET');

            if (
$qry->num_rows() == 1) {;
                return 
true;
            } else {
                return 
false;
            }
        }
    } 



RE: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli - RobertSF - 03-10-2015

It doesn't seem to be anything you're doing. It looks like it might be an issue with your host's implementation of MySQL. Does your problem start when you move your application from your local computer to your internet host? I suppose it could also be a bug in Codeigniter. Check out thisĀ Stack Overflow question.


RE: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - CroNiX - 03-11-2015

Try naming the pvpgn property (your db connection) something different in your pvpgn model.


RE: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - Narf - 03-12-2015

The error means just that your DB connection isn't initialized yet ... set 'autoinit' to TRUE.


RE: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - madaan_tushar - 05-26-2015

Please, check your username and password.


RE: Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given - Happy Camper - 05-26-2015

Assuming your login details are correct try changing localhost to 127.0.0.1