Igniter code: Calling the member function num_rows () on an object without an object

I developed an app in codeigniter on localhost ... the app works fine .. then I uploaded the app to a temporary server ... and after logging into the admin panel I get this error ... but if I run the same app in localhost it works fine ...

Mistake

  Fatal error: Call to a member function num_rows() on a non-object in  /home/u520606051/public_html/application/models/loginmodel.php on line 9

      

this is my model:

function validate($data)
{
    $query = $this->db->get_where('users', $data);
    if($query->num_rows() == 1)
    {
        return true;
    }
}

      

controller

function verifyUser()
{
    //getting parameters from view 
    $data = array(
            'username' => $this->input->post('username'),
            'password' => $this->input->post('password')
        );      
    $this->load->model('loginModel'); 
    $query = $this->loginModel->validate($data);

    if ($query)
    {
        //if the user c validated
        //data variable is created becx we want to put username in session
        $data = array(
                'username' => $this->input->post('username'),
                'is_logged_in' => true  
            );

        $this->session->set_userdata($data);
        redirect('sessionController/dashboard_area');
    }
    else
    {
        $this->index();
    }
    }

      

Modal filename:

  loginmodel.php

 class Loginmodel extends CI_Model 

      

controller file name

loginController.php

 class LoginController extends CI_Controller 

      

+3


source to share


2 answers


Well, I came up with a solution myself. It was not actually loading the database and so when I want to query and select the result I was getting this error and finally when I checked the databse.php file there is a white space in the database name so I deleted it .. thank you everybody



+3


source


Without seeing the filenames, I can't guarantee, but this is almost certainly the case where you named your model with different capitalizations in the filename, class name, and (load) name.

Your localhost is most likely Windows, which doesn't care; your server is most likely Linux which is case sensitive



Go back and make sure everything is the same and you'll be fine

0


source







All Articles