Hax0r
Hax0r

Reputation: 1803

Codeigniter real_escape_string function can't call

I have added the line below from my models

$this->db->close();

And then this code gives me an error

Severity: error --> Exception: Call to a member function real_escape_string() on boolean  

Any advice or suggestion would be appreciated.

UPDATE: Here are the configs I use. Main DB connection

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'is my host address',
    'username' => 'is my id',
    'password' => 'is my password',
    'database' => 'is my database name',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => APPPATH.'cache/db/',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Upvotes: 1

Views: 7245

Answers (1)

Sonali Hajarnis
Sonali Hajarnis

Reputation: 187

Your DBdriver is mysqli so you have to use real_escape_string() because its belong from mysql dbdriver

You can use $this->db->escape_str() or $this->db->escape() function of codeigniter

Upvotes: 2

Related Questions