开发者

How do I write a prepared statement with an update?

开发者 https://www.devze.com 2022-12-23 21:03 出处:网络
I am using mysqli prepared statments and I am trying to write a prepared statement with an UPDATE, but I think I am off somewhere.

I am using mysqli prepared statments and I am trying to write a prepared statement with an UPDATE, but I think I am off somewhere.

Here's my code:

$upload_folder = 'Some String';
$sql = 'UPDATE orders (upload_location)
        SET (?)
        WHERE order_id = 160';

$stmt = $conn->stmt_init();
if($stmt->prepare($sql)){
  $stmt->bind_param('s', $upload_folder);
  $location_inserted = $stmt->execute();
}

What am I doin开发者_如何学编程g wrong?


SET foo = ?

You haven't specified which column to update.


the correct sql-syntax for update is:

UPDATE table SET column = ?


you are using SET keqword instead of VALUES as it's supposed by query format.

0

精彩评论

暂无评论...
验证码 换一张
取 消