I'm trying to convert all my non-prepared queries into prepared statements.
In the following code I have commented out the working old query, above it is the new prepared statement. However it's not working for me. Does anyone see anything wrong with this?
<?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;
?>