多年来,我一直盯着这个查询,试图找出为什么我会收到标题中所述的错误,但我一生都无法纠正它。所有字段均正确,并且所有 POST 值均已正确发布。如果有新眼光的人能够指出其中的错误,我将不胜感激。非常感谢。
$id = $_POST['id'];
$rack = strtoupper($_POST['slot']);
$column = $_POST['column']; <---INT
$row = $_POST['row']; <---INT
$bay = $_POST['bay']; <---INT
$size = $_POST['size'];
$service = ucfirst($_POST['service']);
$activity = ucwords($_POST['activity']);
$dept = $_POST['dept'];
$company = $_POST['company'];
$address = ucwords($_POST['address']);
$user = ucwords($_POST['user']);
$box = $_POST['item
'];
$query = "UPDATE `boxes` SET `rack` = '".$rack."',`column` = $column,`row` = $row,`bay` = $bay,`status` = '1',`customer` = '".$company."', `department` = '".$dept."',`request` = 0,`custref` = '".$box."',`size` = '".$size."',`authorisation` = '".$user."' WHERE `department` = '".$dept."',`customer` = '".$company."',`custref` = '".$box."'";
mysqli_query($conn, $query) or die('Error, box action failed'. mysqli_error($conn));
最佳答案
您应该在 WHERE
中使用 AND
而不是 ,
改变
WHERE `department` = '".$dept."',`customer` = '".$company."',`custref` = '".$box."'";
至
WHERE `department` = '".$dept."' AND `customer` = '".$company."' AND `custref` = '".$box."'";
关于php - 更新时Mysql语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50873009/