• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when trying to get data through controller

I am new to codeigniter and I am getting the following error

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$welcome_model

Filename: controllers/welcome.php

Line Number: 45

Fatal error: Call to a member function get_page() on a non-object in C:\wamp\www\xyz\application\controllers\welcome.php on line 45

My welcome controller has the following
public function view($pagename)


$data['details'] = $this->welcome_model->get_page($name);

if (empty($data['page_details']))




My welcome_model has the following

public function get_page($name = 'Hi'){
            $query=$this->db->query("call spGet($name)");
            return $query->result();

Can Anybody help me as to why I am getting this error?

Maybe you didn't load the model.

Try loading the model in your controller like this:

Thansk that helped

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.