简体   繁体   English

语法错误

[英]Apparent Syntax Error

I will be the first to admit I am bit of a newbie when it comes to PHP however I am having a really frustrating issue where I am trying to submit data which is collected from a form (currently preset in the query) and then send it to the database, my problem is that its saying my Syntax is incorrect, however from what I have found it is not and I do not have access to modify the database as it is a university server. 我将是第一个承认我是PHP的新手,但是我遇到了一个非常令人沮丧的问题,我试图提交从表单收集的数据(当前在查询中预先设置),然后将其发送对于数据库,我的问题是它说我的语法不正确,但是从我发现的事实来看,这是不正确的,并且我无权修改数据库,因为它是大学服务器。

mysql_query("INSERT INTO 'nnProduct' VALUES ('', 'Something','Something','Something',5,5,'$image_name', $productTypeID)");

The error I am having is this 我遇到的错误是这样

Invalid query: 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 ''nnProduct' VALUES ('', 'Something','Something','Something',5,5,'aaron.jpg', 1)' at line 1 检查与您的MySQL服务器版本相对应的手册以获取在``nnProduct''VALUES(``,'Something','Something','Something',5,5,'aaron.jpg',1)附近使用的正确语法'在第1行

You cannot wrap your table name in quotes. 您不能将表名用引号引起来。 You need to use ticks (or no ticks or quotes): 您需要使用刻度(或没有刻度或引号):

mysql_query("INSERT INTO `nnProduct` VALUES ('', 'Something','Something',...
                       ^^^^^     ^^^^
                            HERE

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

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