我试图将所有未准备好的查询转换为准备好的语句。
在下面的代码中,我已经注释掉了工作中的旧查询,上面是新编写的语句。但是它不适合我。有没有人看到这个有什么问题?
<?php
require_once 'pdocon.php';
if (isset($_POST['card_id'])) {
$card_id = ($_POST['card_id']);
$rowname = ($_POST['rowname']);
$rowothervalue = ($_POST['rowothervalue']);
$stmt = $conn->prepare("UPDATE cards SET :rowname = :rowothervalue WHERE id= :card_id");
$stmt->bindParam(':rowname', $rowname);
$stmt->bindParam(':rowothervalue', $rowothervalue);
$stmt->bindParam(':card_id', $card_id);
$stmt->execute();
// $status_sql='UPDATE cards SET '.$rowname.' = '.$rowothervalue.' WHERE id=' . $card_id . '';
// $status_result = $conn->query($status_sql);
}
$conn = null;
?>