Could somebody please explain to me why I am receiving the below error, I have received it many times before and have not found out why:
Fatal error: Call to a member function category_exists() on a non-object in C:\wamp\www\application\controllers\news.php on line 50
The controller (news.php):
public function category($category, $id, $title)
{
if ($this->news_model->category_exists($category) == true) {
echo 'true';
} else {
echo 'false';
}
}
The model:
public function category_exists($category)
{
$this->db->where('news_category', $category);
$query = $this->db->get('news_category');
if ($query->num_rows() > 0) {
return true;
} else{
return false;
}
}
If you could explain what the error means and why it is a non-object or how to turn it into an object that would be great.
EDIT: MODEL IS AUTOLOADED
Copied to answer:
I may be off, but aren't model names case sensitive? So if your model is class News_model it should be called by $this->News_model->category_exists. (though you have omitted the declaration, so this is only a guess)