[英]Unexpected PHP behaviour updating database
This query is not updating the database entry with id=0000000001 in my php code.此查询不会更新我的 php 代码中id=0000000001的数据库条目。 After executing this query the database entry remain same as it was before.
执行此查询后,数据库条目保持不变。
$sql = "UPDATE inventory SET (itemName=$item_name, description=$description,
supplierCode=$supplier_code, cost=$cost, price=$sell_price,onHand=$num_on_hand,
reorderPoint=$reorder_point, backOrder=$back_order) WHERE id=0000000001;";
$x = $connection->prepare($sql);
$connection->query($sql);
$sql = "UPDATE inventory
SET itemName='$item_name',
description='$description',
supplierCode='$supplier_code',
cost='$cost',
price='$sell_price',
onHand='$num_on_hand',
reorderPoint='$reorder_point',
backOrder='$back_order'
WHERE id='0000000001';";
Try this one.试试这个。
Try this尝试这个
$x = $connection->prepare("UPDATE inventory SET (itemName=?, description=?,
supplierCode=?, cost=?, price=?,onHand=?,
reorderPoint=?, backOrder=?) WHERE id=0000000001");
$x->bind_param('ssiiiiii',$item_name,$description,$supplier_code,$cost,$sell_price,$num_on_hand,$reorder_point,$back_order);
$x->execute();
I am assuming that supplierCode, cost,price,onHand,reorederPoint and backOrder are of type int
我假设
supplierCode, cost,price,onHand,reorederPoint and backOrder are of type int
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.