Welcome Guest, Not a member yet? Register   Sign In
atal error: Call to a member function get_duke() on a non-object in
#1

[eluser]anna16[/eluser]
Hello guys

I have small errors can you help me please.

The error,
Code:
Fatal error: Call to a member function get_duke() on a non-object in /home/herpescu/public_html/ci/application/userauth/controllers/site.php on line 10

controller,
Code:
<?php

class Site extends Controller
{
    function __construct()
    {
        parent::Controller();
      $this->is_logged_in();
    
        if($query = $this->membership_model->get_duke())
        {
            $data['records'] = $query;
        }
        
    $this->load->view('meter', $data);
    }


    function members_area()
    {
        $this->load->view('logged_in_area');
    }
    
    function another_page() // just for sample
    {
        echo 'good. you\'re logged in.';
    }

    function meter_area()
    {
        $this->load->view('meter');
    }
    
    function is_logged_in()
    {
        $is_logged_in = $this->session->userdata('is_logged_in');
    $cur_method = $this->router->method;
    
    if($cur_method != 'meter_area') //do the task if the url is not meter_area
    {
            if(!isset($is_logged_in) || $is_logged_in != true)
            {
                echo 'You don\'t have permission to access this page. <a href="../login">Login</a><br>';
    
                die();        
                //$this->load->view('login_form');
            }
    }            
    }    

    function contactus(){
        $this->load->helper('url');
        if ($this->input->post('amount')){
            $this->load->model('MContacts','',TRUE);
            $this->MContacts->addContact();
            redirect('site/thankyou','refresh');
        }else{
            redirect('site/members_area','refresh');
        }
    }
  
    function thankyou(){
        $data['title'] = "Thank You!";
        $data['headline'] = "Thanks!";
        $this->load->view('thankyou');    
    }  
}

model,
Code:
&lt;?php

class Membership_model extends Model {

    function validate()
    {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('membership');
        
        if($query->num_rows == 1)
        {
            return true;
        }
        
    }
    
  function get_duke() {
    //$query = $this->db->get('data');
        //return $query->result();
    
    $query = $this->db->query("SELECT org_name, count(amount) AS total FROM organization WHERE='duke'");
    return $query->result();
    
  }

    function create_member()
    {
                
        $new_member_insert_data = array(
            'first_name' => $this->input->post('first_name'),
            'last_name' => $this->input->post('last_name'),
            'email_address' => $this->input->post('email_address'),
            'country' => $this->input->post('country'),            
            'username' => $this->input->post('username'),
            'password' => md5($this->input->post('password')),
            'date_registered' => date("Y-j-n"),
            'ip_address' => $_SERVER['REMOTE_ADDR']
        );
        
        $insert = $this->db->insert('membership', $new_member_insert_data);
        return $insert;
    }
}



Thank you very much in advance.
#2

[eluser]jmadsen[/eluser]
at a quick glance, it looks like you are not loading "membership_model" before you use it.

i.e., $this->load->model('membership_model');
#3

[eluser]Buso[/eluser]
seems like you haven't loaded the model, try with:
Code:
$this->load->model('membership_model');
#4

[eluser]anna16[/eluser]
Thanks guys.




Theme © iAndrew 2016 - Forum software by © MyBB