致命错误:在第43行的C:\ xampp \ htdocs \ TugasWeb2 \ application \ controllers \ login.php中的非对象上调用成员函数check_user()

时间:2014-12-27 10:06:46

标签: codeigniter codeigniter-2

我的代码有什么问题?

$count=$this->db_ecommerce->check_user($user, $pswd)->num_rows(); <-- this line 43

        $user=$this->input->post('username');
        $pswd=$this->input->post('password').$this->config->item("key_login");
        //$pswd=$this->input->post('password');
        $count=$this->db_ecommerce->check_user($user, $pswd)->num_rows();
        if($count>0) {
            $this->session->set_flashdata('status_login', 'ok');
            redirect('member');

2 个答案:

答案 0 :(得分:0)

假设您已经有一个名为db_ecommerce的模型,您应该尝试加载它:

$this->load->model('db_ecommerce');
$count=$this->db_ecommerce->check_use ...

答案 1 :(得分:0)

在获得num_rows()之前,您应该检查是否有任何结果:

 $count = $this->db_ecommerce->check_user($user,$pswd);
 if($count){
     $count = $count->num_rows();
 }
 else{
     $count = 0;
 }