i have developed a app in codeigniter on localhost ...the app works fine .. then i uploaded the app into temporary server ... and after login into the admin panel i am getting this error..but if i run the same app in localhost it works fine ...
error
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 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();
}
}
file name Of Modal:
loginmodel.php
class Loginmodel extends CI_Model
file name of Controller
loginController.php
class LoginController extends CI_Controller
well i came up a solution by myself ..actually it was not loading the database and thus when i want to query and selecting the result i was getting this error and finally when i checked my databse.php file there is a white space in the name of database so i removed it .. thanks for all of you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With