0
我測試過它,SESSION ID發出一個有效的ID,所有其他參數也一樣。幫我。PDO查詢不起作用
$sql = 'UPDATE users SET firstname = :firstname, lastname = :lastname WHERE id = :id';
$records->bindParam(':id',$_SESSION['user_id']);
$stmt = $conn->prepare($sql);
list($firstname, $lastname) = explode(' ', $nn);
$stmt->bindParam(':firstname', $firstname);
$stmt->bindParam(':lastname', $lastname);
if($stmt->execute()) {
} else {
die("An error adapted during changes.");
}
呃...你綁定$記錄,而不是$ stmt的ID。另外,你需要在prepare()之後執行bindParam(); – junkfoodjunkie