Possible Duplicate:
Can a number used to name a sql column
我试图找出这段代码有什么问题
$query = "UPDATE $table SET '$_GET[qty]'=$_GET[newprice] WHERE 'id'='1'";
this is what $query looks like - UPDATE retail_12x18 SET '25'=100 WHERE 'id'='1'
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 ''25'=100 WHERE 'id'='1'' at line 1
我已经在各个方向都加上了反引号,但无法让它通过,总是出现相同的错误消息。
最佳答案
在字段名称周围使用反引号:
UPDATE table SET `25` = '{thevalue}', `100` = '{thevalue}', `200` = '{thevalue}' WHERE wherefield = '{wherevalue}'
参见此处(查找反引号
单词):http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
关于PHP mysql_query - 使用所有变量更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7973780/