Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更新数据库时出现意外的PHP行为_Php_Mysql_Sql_Database - Fatal编程技术网

更新数据库时出现意外的PHP行为

更新数据库时出现意外的PHP行为,php,mysql,sql,database,Php,Mysql,Sql,Database,此查询不会在我的php代码中更新id=000000000 1的数据库条目。执行此查询后,数据库条目保持与以前相同 $sql = "UPDATE inventory SET (itemName=$item_name, description=$description, supplierCode=$supplier_code, cost=$cost, price=$sell_price,onHand=$num_on_hand, reorderPoint=$reorder_poin

此查询不会在我的php代码中更新id=000000000 1的数据库条目。执行此查询后,数据库条目保持与以前相同

$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);
试试这个

试试这个

$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();

我假设
供应商代码、成本、价格、现货、再订购点和延期订单的类型为int

始终尝试将值放在引号中
可能是错误的”;“id=000000000 1之后,您的列长度设置为多少;可能太低。在查询发送到数据库后,请始终检查返回的错误。如果列长度正常,请尝试删除查询中的
$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();