开发者

What's wrong with this sql code?

If I remove the line condition=\''.$this->condition.'\', it works.

If I let it there, the following error message appears:

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 'condition='unknown', promotional='0', website='0', quantity='1', ' at line 7

mysql_query('UPDATE products SET 
            name = \''.$this->name.'\', 
            description = \''.$this->description.'\',
            brand = \''.$this->brand.'\',
            model = \''.$this->model.'\',   
            price=\''.$this->price.'\', 
            co开发者_高级运维ndition=\''.$this->condition.'\', 
            promotional=\''.$this->promotional.'\', 
            website=\''.$this->website.'\', 
            quantity=\''.$this->quantity.'\',
            service=\''.$this->service.'\'  
            WHERE id = \''.$this->id.'\' '


CONDITION is a reserved mysql keyword. You must enclose it in backticks:

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


You have to rename condition column. See Reserved MySQL keywords table

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜