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

#1
[eluser]bleu[/eluser]
I am new to codeigniter and I am getting the following error

Code:
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
Code:
public function view($pagename)
{

print_r($this);

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

if (empty($data['page_details']))
{
  show_404();
}


  $this->load->view('top');
  $this->load->view('bar',$data);
  

$this->load->view('bottom');



}


My welcome_model has the following

Code:
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?

#2
[eluser]Glazz[/eluser]
Maybe you didn't load the model.

Try loading the model in your controller like this:
Code:
$this->load->model('your_model_name_here');

#3
[eluser]bleu[/eluser]
Thansk that helped


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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