0

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;
        }
}

正しいクレデンシャルを使用してログインしても問題はありません。間違ったパスワードを入力すると、そのエラーが発生します。どんな助けでも大歓迎です。

4

1 に答える 1

8

構文エラーがあります:

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

次のようにする必要があります。

if ($q->num_rows > 0) {
    return $q->row();
}

あなたは忘れた{

于 2012-05-22T15:05:02.210 に答える