• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI error: get_where() on a non-object

#1
Hello,

I am receiving this error messages:


Fatal error: Call to a member function get_where() on a non-object in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\models\gallery_model.php on line 10

line 10:  
Code:
 $query = $this->db->get_where('galleries_pictures',array('pic_id'=> $pic_unique_id));


model:
Code:
class Gallery_model extends CI_Model {
   public function get_picture($pic_unique_id)
   {
       $query = $this->db->get_where('galleries_pictures',array('pic_id'=> $pic_unique_id));
       return $query->result();
   }
}

controller:
Code:
public function index()
{
  $this->load->helper('url');
   $this->load->model('gallery_model');//loads model
   $data['pic']  = $this->gallery_model->get_picture($pic_unique_id);//calls to model function
   $this->load->view('index',$data);//loads view with data
}


view:
Code:
<?php foreach($pic as $pic_item) { ?>
<img src="<?php echo base_url(assets1/images/slider/).$pic_item->pic_item; ?>">
<?php } ?>

I wonder how to fix the error message?
Reply

#2
do you connect to any database?

in the db var is not the database object...
Reply

#3
Did you autoload the database library



PHP Code:
$autoload['libraries'] = array('database'); 


Your file name is also incorrect should have first letter upper case only

Change

gallery_model.php

To

Gallery_model.php
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#4
Let us know you things went
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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