Welcome Guest, Not a member yet? Register   Sign In
DB connection problem
#1

[eluser]razorsese[/eluser]
I have a database called : product and 2 tables in it : bookmarks and pname

When i try to get the information from table bookmarks i get the following error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: index::$mods

Filename: controllers/index.php

Line Number: 34

Code that i'm using :
Code:
class index extends CI_Controller{

     public function __construct()
{
    parent::__construct();
  
}


function display_records()
{

    $query = $this->db->get('bookmarks');
    
  foreach($query->result() as $row)
       {
  $result[]= $row->bookmark;
              
        }

        return $result;

}


    function index()
{
    
        $data['names'] = $this->mods->display_records();
  $this->load->view('index_view',$data);
  
}



}
#2

[eluser]Unknown[/eluser]
have you loaded the model mods in autoload.php or else load the model in the index function $this->load->model('mods')
#3

[eluser]razorsese[/eluser]
Now it works fine if i move the code to views->index_view.php




Theme © iAndrew 2016 - Forum software by © MyBB