php - 更新时Mysql语法错误

标签 php mysql

多年来,我一直盯着这个查询,试图找出为什么我会收到标题中所述的错误,但我一生都无法纠正它。所有字段均正确,并且所有 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/

相关文章:

php - 样式表和 Symfony

php - 如何将帖子(变量)信息传递到第二页

mysql - 在 MySQL 的同一个表中创建 2 个 AUTO _INCREMENT 列

java - 多对多删除集 NULL

java - 连接到远程 Amazon RDS mysql 实例的桌面应用程序

php - 我可以相信 mysql_insert_id() 返回正确的值,多线程偏执狂

php - 在 PHP 中创建 XLS 文件的最佳方法是什么

mysql - 检查大表中的重复项

mysql - 来自服务器的错误 (RequestEntityTooLarge) : Request entity too large: limit is 3145728 while creating a configMap

javascript - 通过 jQuery Ajax 加载图像