这一个返回布尔(假)
function authenticate($user, $pass){
$sql = "SELECT * FROM Users ";
$sql .= " WHERE UniqueUser = \"{$user}\" ";
$sql .= " AND HashedPass = \"{$pass}\" ";
$sql .= " LIMIT 1";
$result = mysqli_query($sql);
$result_set = mysqli_fetch_array($result);
return !empty($result_set) ? array_shift($result_set) : false;
}
如果搜索任何其他数据库列,如firstname,则返回lastname 整行,一切进展顺利
function authenticate($user, $pass){
$sql = "SELECT * FROM Users ";
$sql .= " WHERE LastName= \"{$user}\" ";
$sql .= " AND HashedPass = \"{$pass}\" ";
$sql .= " LIMIT 1";
$result = mysqli_query($sql);
$result_set = mysqli_fetch_array($result);
return !empty($result_set) ? array_shift($result_set) : false;
}
为什么有些列有时候没有按预期工作?