2017-06-13 1 views
0

ログインシステムをプロジェクトに作成しようとしていますが、ログイン中にエラーが発生しました。エラーは 'next()はパラメータ1が配列で、ブール値が与えられると期待しています'と言っています。next()は、パラメータ1が配列で、booleanが指定されています。

public function login(Customer $c) { 
     $sql = "select * from customer where username = ? and password = ?"; 

     try { 
      $username = $c -> getUsername(); 
      $password = $c -> getPassword(); 

      $stmt = $this -> getConnection() -> prepare($sql); 
      $stmt -> bind_param('ss', $username, $password); 
      $res = $stmt -> execute(); 

      while (next($res)) {//error occurred on this line 
       return true; 
      } 

     } catch (SQLiteException $ex) { 
      echo $ex; 
     } 

     return false; 
    } 
+1

は '$ stmt->実行()'を返す可能性のあるものを値を参照するマニュアルを参照してください... –

答えて

2

execute()は、成功するとtrueを返し、失敗するとfalseを返します。このような

用途:

$stmt->execute(); 
while($row = $stmt->fetch_assoc()) 
{ 
    return true; 
}