Jed
Jed

Reputation: 1043

Codeigniter can't find models

On my local system code ignitor works perfectly however when I upload my code to the shared host I get this error.

Unable to locate the model you have specified: Usermodel

My models folder has a UserModel.php with a UserModel class inside it. Please tell me what I am doing wrong or what config I need to set

class UserModel extends CI_Model
{
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

 $username = $this->input->post('Username');
        $password = $this->input->post('Password');
        if(isset($username) && isset($password))
        {
            $this->load->model('UserModel');

            /**
             * @property UserModel $UserModel
             */
            $result = $this->UserModel->validateLogin($username,$password);
            if($result)
            {
                $this->session->set_userdata('username',$username);
                $this->session->set_userdata('password',$password);
                header('Location: /dashboard');
            }
            else
            {
                $loginFailure = true;
            }
        }
        $data['loginFailure'] = $loginFailure;
		$this->load->view('user/login_view',$data);

$route['login'] = "User/login";

Upvotes: 1

Views: 144

Answers (1)

mmccaff
mmccaff

Reputation: 1281

You likely developed this on Windows which is case-insensitve when referencing filenames, whereas your shared host is likely Linux, which is case-sensitive.

From the error you pasted, it's failing to load "Usermodel".

Try renaming your model's file to usermodel.php and loading 'usermodel':

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

Or, just renaming UserModel.php to Usermodel.php.

Upvotes: 1

Related Questions