Welcome Guest, Not a member yet? Register   Sign In
undefined property
#12

[eluser]f0n3man[/eluser]
Here's the code just run with the same error:
Code:
Controller:

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();
        $this->load->database();
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->model('site_model');
        $this->output->enable_profiler(TRUE);
    }

    function index()
    {
        $data['records'] = $this->site_model->get_records();
        $this->load->view('site_view', $data);
    }

Model:

class Site_model extends CI_Model {

function Site_model()
    {
        parent::CI_Model();
    }
    
    function get_records()
    {
            $q = $this->db->get('data');
        
        if($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                $data[] = $row;
            }
        return $data;
        }
    }

Screen Error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$site_model

Filename: controllers/welcome.php

Line Number: 17

error.log entry:

PHP Fatal error: Call to a member function get_records() on a non-object in /path-to-files/application/modules/welcome/controllers/welcome.php on line 17


Messages In This Thread
undefined property - by El Forum - 10-07-2010, 10:13 AM
undefined property - by El Forum - 10-07-2010, 10:25 AM
undefined property - by El Forum - 10-07-2010, 12:51 PM
undefined property - by El Forum - 10-07-2010, 12:53 PM
undefined property - by El Forum - 10-07-2010, 01:09 PM
undefined property - by El Forum - 10-07-2010, 01:30 PM
undefined property - by El Forum - 10-07-2010, 02:00 PM
undefined property - by El Forum - 10-07-2010, 04:56 PM
undefined property - by El Forum - 10-07-2010, 05:12 PM
undefined property - by El Forum - 10-07-2010, 05:17 PM
undefined property - by El Forum - 10-08-2010, 08:21 AM
undefined property - by El Forum - 10-08-2010, 12:26 PM
undefined property - by El Forum - 10-08-2010, 01:32 PM
undefined property - by El Forum - 10-08-2010, 01:40 PM
undefined property - by El Forum - 10-09-2010, 12:20 AM
undefined property - by El Forum - 10-09-2010, 05:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB