Welcome Guest, Not a member yet? Register   Sign In
500 Server when load model
#1

[eluser]drseuss[/eluser]
Hi... Every time I run the page, and it gets to loading the login_model I get a 500 internal server error... and when I comment out the load->model it doesn't error.

here are the pages

login.php - controller
Code:
class Login extends CI_Controller {

    function index() {
        $this->load->view('login');
    }
    
    function verify() {
        $this->load->model('login_model');
        $query = $this->login_model->verify_credentials();
        
        $query = true;
        
        if($query) {
        
            $session_data = array(
                'email'=>$this->input->post('email'),
                'is_logged_in'=>true
            );
            
            $this->session->set_userdata($session_data);
            
            redirect('game');
            
        } else {
        
            $this->index();
            
        }
        
    }
        
    
}

login_model.php - model
Code:
class Login_model extends Model {

    function verify_credentials() {
    
        $this->db->where('email',$this->input->post('email'));
        $this->db->where('password',$this->input->post('password'));
        $query = $this->db->get('accounts');
        
        if($query->num_rows == 1) {
            return true;
        }
    }
    
}
#2

[eluser]InsiteFX[/eluser]
Your missing your Constructor in your Controller!
Code:
class Login extends CI_Controller {

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

    function index() {
        $this->load->view('login');
    }
    
    function verify() {
        $this->load->model('login_model');
        $query = $this->login_model->verify_credentials();
        
        $query = true;
        
        if($query) {
        
            $session_data = array(
                'email'=>$this->input->post('email'),
                'is_logged_in'=>true
            );
            
            $this->session->set_userdata($session_data);
            
            redirect('game');
            
        } else {
        
            $this->index();  
        }
    }
          
}

InsiteFX
#3

[eluser]drseuss[/eluser]
I added the code as you did. It still didn't work. I am doing this on a localhost linux laptop. idk if that helps any. I've been trying all day.
#4

[eluser]CroNiX[/eluser]
If its CI2, its model_name extends CI_Model, just like extending the CI_Controller
#5

[eluser]InsiteFX[/eluser]
Opp's missed that one CroNix, thats what happens when your up all night reinstalling Windows 7 Pro and all updates and applications. Get kind of buggy eyed!

InsiteFX
#6

[eluser]drseuss[/eluser]
Smile That fixed it. Thanks you both of you guys help.
#7

[eluser]danmontgomery[/eluser]
[quote author="InsiteFX" date="1299057706"]Your missing your Constructor in your Controller![/quote]

Constructors are inherited like everything else. If you're not doing any extra work after the parent's, the constructor is unnecessary.
#8

[eluser]InsiteFX[/eluser]
I go was just going by the CI 2.0 guide lines.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB