简体   繁体   English

这个sql代码有什么问题?

[英]What's wrong with this sql code?

If I remove the line condition=\\''.$this->condition.'\\', it works. 如果我删除行condition=\\''.$this->condition.'\\',它可以工作。

If I let it there, the following error message appears: 如果我在那里,会出现以下错误消息:

You have an error in your SQL syntax; 您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition='unknown', promotional='0', website='0', quantity='1', ' at line 7 查看与您的MySQL服务器版本对应的手册,以便在'condition ='unknown',promotional ='0',website ='0',quantity ='1','在第7行附近使用正确的语法

mysql_query('UPDATE products SET 
            name = \''.$this->name.'\', 
            description = \''.$this->description.'\',
            brand = \''.$this->brand.'\',
            model = \''.$this->model.'\',   
            price=\''.$this->price.'\', 
            condition=\''.$this->condition.'\', 
            promotional=\''.$this->promotional.'\', 
            website=\''.$this->website.'\', 
            quantity=\''.$this->quantity.'\',
            service=\''.$this->service.'\'  
            WHERE id = \''.$this->id.'\' '

CONDITION is a reserved mysql keyword . CONDITION是一个保留的mysql关键字 You must enclose it in backticks: 你必须用反引号括起来:

`condition`=\''.$this->condition.'\', 

You have to rename condition column. 您必须重命名condition列。 See Reserved MySQL keywords table 请参阅保留的MySQL关键字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM