2017-06-13 115 views
0

我正在尝试为我的项目创建一个登录系统,但在登录期间发生错误。错误说'next()期望参数1是数组,布尔给定'。next()期望参数1是数组,布尔值给出

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->的execute()'可能会返回... –

回答

2

execute()在成功时返回true或在失败时返回false。

使用这样的:

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