Possible Duplicate:
Call to a member function on a non-object
Call to a member function on a non-object
When i try to access the database using CodeIgniters Active records it always gives me the error
Fatal error: Call to a member function insert() on a non-object
Fatal error: Call to a member function get() on a non-object
below is the settings in my database
$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;
and i have auto-loaded it
$autoload['libraries'] = array('database','session');
and below is my model
class Leads_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function insertq(){
$q=$this->db->insert('test',$data);
if ($q){
return true;
}
else
{
return false;
}
}
}
can someone please suggest me what am i doing wrong and why am i getting that error?