當我使用下面的代碼時,我得到Undefined Index: email on $row['email']
。如果我用$row
和print_r獲取整個數組,它將顯示它應該顯示的樣子。 我哪裏錯了?fetchAll(PDO :: FETCH_ASSOC)不返回單個值
$stmt = $db->dbh->prepare("SELECT email FROM $this->table WHERE `email`= :email");
$stmt -> bindValue(':email', $email);
$stmt->execute();
while ($row = $stmt->fetchAll()){
return $row['email'];
}
$new = new Users;
echo $new->reset_password($email);
}
'fetchAll' ...獲取所有,使用'fetch' – cmorrissey
既然你的循環,你需要'而($行= $ stmt- > fetch()){'而不是'while while($ row = $ stmt-> fetchAll()){' – Sean
爲什麼你選擇的是你已經知道的電子郵件? –