doucan9079 2014-01-31 11:43
浏览 32
已采纳

表观语法错误

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.

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; 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

  • 写回答

1条回答 默认 最新

  • douxiuar885064 2014-01-31 11:44
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部