-1

これを機能させるのに問題があります。機能するコードと達成しようとしているコードの両方を含めます。最初のコードでは機能せず、エラーメッセージが表示されます。Connection failed: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':userName ANDパスワード=:userPass' at line 1 構文のいくつかの異なる組み合わせを試しましたが、まだうまくいきません。$row2番目のコード例では、動作中のコードであり、基本的に、関数からカウントを取得してクエリに一致する行が1つあることを確認するために、不要なコードをすべて削除しようとしています。

function checkLogin($conn,$myusername, $mypassword) {

       $stmt = $conn->prepare('SELECT COUNT(*) FROM `CLL_users` WHERE `user_name`= :userName AND `password`= :userPass');
       $stmt->bindValue(':userName', $myusername);
       $stmt->bindValue(':userPass', $mypassword);
       $stmt->execute();
       $count = $stmt->fetchColumn();
       return $count;
}
4

1 に答える 1

0
function checkLogin($conn,$myusername, $mypassword) {

           $stmt = $conn->prepare('SELECT COUNT(*) FROM `CLL_users` WHERE `user_name`= :userName AND `password`= :userPass');
           $stmt->bindValue(':userName', $myusername);
           $stmt->bindValue(':userPass', $mypassword);
           $stmt->execute();
           $count = $stmt->fetchColumn();
           return $count;
    }
于 2012-11-04T06:53:52.997 に答える