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 的 PDO 循环返回除第一行之外的所有内容

php - 我想在mysql中查找 friend 关系

Mysql - 选择单行的所有列及其值和列注释

mysql - SQL查询在多对多关系中精确匹配

php - 显示来自 Mysql 的数组信息

mysql - 我的 MySQL 转储的导入还有多长时间?

php - 在 php 上传期间未选择文件时禁用提交按钮

php - 如何启动我从github下载的laravel项目

php - 尝试在 Console.log 中获取非对象的属性

php - 计算 View 中的结果数