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

[eluser]drseuss[/eluser]
Ok... title says it and I can't fix it.

Error:


A PHP Error was encountered

Severity: Notice

Message: Undefined property: Account::$account_model

Filename: controllers/account.php

Line Number: 21 (This line is: $query = $this->account_model->login(); )


( ! ) Fatal error: Call to a member function login() on a non-object in C:\wamp\www\application\controllers\account.php on line 21
Call Stack
# Time Memory Function Location
1 0.0022 694208 {main}( ) ..\index.php:0
2 0.0076 765744 require_once( 'C:\wamp\www\system\core\CodeIgniter.php' ) ..\index.php:163
3 0.1329 4147912 call_user_func_array ( ) ..\CodeIgniter.php:297
4 0.1329 4147992 Account->login( ) ..\CodeIgniter.php:0


account.php (controller)
Code:
class Account extends CI_Controller {

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

    function login() {

        $this->load->model('account_model');

        $query = $this->account_model->login();

        //$accountId = $this->account_model->account_info('id');
        
        if($query) {

            $session_data = array(

                'email'=>$this->input->post('email'),

                'accountId'=>$accountId->id,

                'is_logged_in'=>true

            );

            $this->session->set_userdata($session_data);

            //redirect('character');
            echo "oh yea!";

        } else {

            $data['error'] = "Bad login information supplied. <br />";

            $this->load->view('home',$data);

        }
        
        
    }
}

account_model.php (model)

Code:
class Account_model extends CI_Model {

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

    function login() {
    
        $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;
        }
    }
}

If anything else is needed just tell me
#2

[eluser]InsiteFX[/eluser]
Did you load the database?

You can autoload it in application/config/autoload.php

InsiteFX
#3

[eluser]drseuss[/eluser]
Yes I did. This is my library autoload

Code:
$autoload['libraries'] = array('database','session','display');

display is my own to quick load the view that I specify, with the header and footer files
#4

[eluser]InsiteFX[/eluser]
Did you save your model file with all lowercase characters?

Also this is wrong!
Code:
if($query->num_rows == 1)
{
    return true;
}

// should be
if($this->query->num_rows() > 0)
{
    return true;
}

InsiteFX
#5

[eluser]drseuss[/eluser]
Yes I've saved it as all lowercase characters...

and I've made the change and it still doesn't work
#6

[eluser]InsiteFX[/eluser]
You did setup all your database parameters in application/config/database.php ?

This is telling me that your model is not loading!

Try autoloading it and see if it works.

InsiteFX
#7

[eluser]drseuss[/eluser]
Yes I've set all my database info
I've tried autoloading it and it isn't working.

I've used the code before, but when I copied the code to my current project it stopped working..
#8

[eluser]byde[/eluser]
may be you are saving your model in a wrong folder
#9

[eluser]drseuss[/eluser]
no it is in the correct folder
#10

[eluser]InsiteFX[/eluser]
Try a clean install of CodeIngniter and redo it.

I know some people have been having problems cutting and pasting code!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB