<分区>
我正在使用 php 对数据库运行基本更新,但我遇到了 SQL 语法错误,而且我一辈子都看不出哪里出了问题。数据库中的字段称为订单,它设置为 int(8)。我尝试将其更改为 smallint 和 varchar,增加了但没有快乐。我也尝试修改查询中的 ' 和 "。代码如下......
$query = "UPDATE gigs SET order='$order' WHERE gig_id='$id'";
if ($r = mysql_query($query) ) {
echo "<p>UPDATED:" . $row['year'] ." - " . $row['month'] . " - " . $row['day'] . " = $order</p>";
} else {
echo "<p>" . mysql_error() . "<br />$q</p>";
}
$order 是年月日值组合成一个整数值,例如2013 年 4 月 12 日 = 20130412。
这是我得到的错误信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order='20040802' WHERE gig_id='10'' at line 1 UPDATE gigs SET order='20040802' WHERE gig_id='10'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order='20040804' WHERE gig_id='11'' at line 1 UPDATE gigs SET order='20040804' WHERE gig_id='11'