doucan9079 2014-01-31 19: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 19: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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站