致命错误:调用非对象中的成员函数row()

时间:2014-05-05 11:54:14

标签: php

大家好我有phpsfp autoposter的问题。一切都按照应有的方式设置,但是当我进入登录页面并尝试登录时,我收到此错误:

  
    

致命错误:在第49行的/phpsfp/application/controllers/login.php中调用非对象上的成员函数row()

  

这是login.php文件:

<?php

class Login extends CI_Controller {

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

        $this->load->library(array('encrypt'));
        $this->load->helper(array('cookie'));
        $this->load->model(array('link', 'general'));
    }

    public function index()
    {
        if(get_cookie('login'))
        {
            list($id_user, $password, $access) = explode("|||", get_cookie('login'));
            $qusers = $this->db->query("SELECT id FROM users WHERE id='".$id_user."' AND password='".$password."'");
            if($qusers->num_rows() > 0)
            {
                $this->session->set_userdata(array('username' => $id_user, 'access' => $access, 'logged' => TRUE));
                redirect('index.php/dashboard');
            }
                else
            {
                delete_cookie('login', $this->config->item('link_domain'), $this->config->item('link_basename'), '');
                redirect('index.php/login');
            }
        }
            else
        {
            if($this->session->userdata('logged') == TRUE)
            {
                redirect('index.php/dashboard');
            }

            $this->load->view($this->config->item('view_page_source').'login', 0);
        }
    }

    function auth()
    {
        $username  = $this->general->xss_post($this->input->post('username'));
        $password  = $this->general->xss_post($this->input->post('password'));
        $remember  = $this->general->xss_post($this->input->post('remember'));
        $qusers_nr = $this->db->query("SELECT COUNT(*) as nr FROM users WHERE username='".$username."' ");

        if ($username != '' && $password != '' && $qusers_nr->row()->nr > 0)

        {
            $qusers = $this->db->query("SELECT id, password, access FROM users WHERE username='".$username."'");
            $password_db   = $qusers->row()->password;
            $password_user = $this->encrypt->sha1($password);

            if($qusers->num_rows() > 0 && $password_db == $password_user)
            {
                $this->session->set_userdata(array('username' => $this->encrypt->encode($qusers->row()->id), 'access' => $qusers->row()->access, 'logged'  => TRUE));

                if(!empty($remember))
                {
                    set_cookie(array('name' => 'login', 'value' => $this->encrypt->encode($qusers->row()->id)."|||".$password_db."|||".$qusers->row()->access, 'expire' => time() + 30 * 86400, 'domain' => '.'.$this->config->item('link_domain'), 'path' => $this->config->item('link_basename'), 'prefix' => ''));
                }

                $this->db->query("UPDATE users SET timestamp_login='".time()."' WHERE id='".$qusers->row()->id."'");
                $redirect = $this->session->userdata('redirect');

                if(!empty($redirect))
                {
                    $this->session->unset_userdata(array('redirect' => ''));
                    redirect($redirect);
                }
                    else
                {
                    redirect('index.php/dashboard');
                }
            }
                else
            {
                $this->session->set_flashdata('class_error', ' error');
                $this->session->set_flashdata('class_tooltip', ' tooltip');
                $this->session->set_flashdata('title_error', 'Incorrect username or password !');
                $this->session->set_flashdata('field_username', $username);
                $this->session->set_flashdata('field_password', $password);
                redirect('index.php/login');
            }
        }
            else
        {
            $error = ($qusers_nr->row()->nr > 0) ? "The fields are empty !" : "This username is invalid !";
            $this->session->set_flashdata('class_error', ' error');
            $this->session->set_flashdata('class_tooltip', ' tooltip');
            $this->session->set_flashdata('title_error', $error);
            $this->session->set_flashdata('field_username', $username);
            $this->session->set_flashdata('field_password', $password);
            redirect('index.php/login');
        }
    }

    function logout()
    {
        $this->load->model(array('faceboook'));
        $this->session->unset_userdata(array('username' => '', 'access' => '', 'logged' => ''));
        $this->session->sess_destroy();
        delete_cookie('login', $this->config->item('link_domain'), $this->config->item('link_basename'), '');
        $this->faceboook->logout();
        redirect('index.php/login');
    }

}

?>
第49行:

if ($username != '' && $password != '' && $qusers_nr->row()->nr > 0)

有谁知道如何解决这个问题?

提前完成。

亚瑟

0 个答案:

没有答案