Call to a member function insert() on a non-object, codeigniter Call to a member function insert() on a non-object, codeigniter codeigniter codeigniter

Call to a member function insert() on a non-object, codeigniter


You're missing $this->load->database();

$this->db->method_name(); will only work when the database library is loaded.

If you plan on using the database throughout your application, I would suggest adding it to your autoload.php in /application/config/.

As others have mentioned, remove the CI_ prefix from your class names. CI_ is reserved for framework classes.


You have to use '$this->load->library('database')' in the model before '$this->db->insert()' or autoload the database library. Go to config folder select autoload.php search for $autoload['libraries'] and replace your empty array() with array('database').


Add autoload libraries in config folder open autoload.php and set $autoload['libraries'] = array('database');