意外的T_STRING,期待T_FUNCTION

0 php mysql codeigniter

使用CodeIgniter学习如何使用php和mysql.遇到那个错误.

我试图检查对我的数据库的登录尝试,它们存储在哪里.以下是我的登录模型中的相关功能:

public function verify_user($email, $password)
    {
        $q = $this
        ->db
        ->where('email_address', $email)
        ->where('password', $password)
        ->limit(1)
        ->get('users');

            if ($q->num_rows > 0)
                return $q->row();
            }
            add_login_attempt($email);
            return false;
        }

        public function add_login_attempt($email)
        {
            $current_attempts = get_login_attempts($email);

            if ($current_attempts > 2)
            {
                lock_account($email);
            }
            else
            {
                $updated_attempts = $current_attempts + 1;
                $data = array('login_attempts' => $updated_attempts);
                $this->db->where('email_address', $email);
                $this->db->update('crm', $data);
            }

        }

        function reset_login_attempts($email)
        {

        }

        function lock_account($email)
        {

        }

        public function get_login_attempts($email)
        {
            $this->db->select('login_attempts');
            $this->db->from('crm');
            $this->db->where('email_address', $email);
            $login_attempts = $this->db->get();

            return $login_attempts;
        }
}
Run Code Online (Sandbox Code Playgroud)

使用正确的凭据登录没有问题.输入错误密码时,会遇到该错误.任何帮助是极大的赞赏.

ila*_*nco 7

您有语法错误:

if ($q->num_rows > 0)
    return $q->row();
}
Run Code Online (Sandbox Code Playgroud)

应该:

if ($q->num_rows > 0) {
    return $q->row();
}
Run Code Online (Sandbox Code Playgroud)

你忘记了 {