Note that there are some explanatory texts on larger screens.

plurals
  1. POFatal error: Call to a member function insert() when using active records in CodeIgniter
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/54566/call-to-a-member-function-on-a-non-object">Call to a member function on a non-object</a><br> <a href="https://stackoverflow.com/questions/254291/call-to-a-member-function-on-a-non-object">Call to a member function on a non-object</a> </p> </blockquote> <p>When i try to access the database using CodeIgniters Active records it always gives me the error</p> <blockquote> <p>Fatal error: Call to a member function insert() on a non-object</p> <p>Fatal error: Call to a member function get() on a non-object</p> </blockquote> <p>below is the settings in my database</p> <pre><code>$active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default']['password'] = ''; $db['default']['database'] = 'test'; $db['default']['dbdriver'] = 'mysql'; $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; </code></pre> <p>and i have auto-loaded it</p> <pre><code>$autoload['libraries'] = array('database','session'); </code></pre> <p>and below is my model</p> <pre><code>class Leads_model extends CI_Model { function __construct() { parent::__construct(); } function insertq(){ $q=$this-&gt;db-&gt;insert('test',$data); if ($q){ return true; } else { return false; } } } </code></pre> <p>can someone please suggest me what am i doing wrong and why am i getting that error?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload