MySQL错误-“您的SQL语法有错误" [英] MySQL error - "You have an error in your SQL syntax"

查看:107
本文介绍了MySQL错误-“您的SQL语法有错误"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到的错误消息:

您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的"word","group","selfnote")附近使用VALUES("item","a","self的注释"))

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 ''word','group','selfnote') VALUES ('item','a','note to self')' at line 1

PHP代码为:

$toq="INSERT INTO articles ('word','group','selfnote') 
VALUES ('$ttle','$wrdr','$snote')";

我正试图找到solutins,但它们似乎没有像回声所给出的那样起作用:

I was trying to find solutins, but they didn't seem to work as echoing gives:

INSERT INTO articles ('word','group','selfnote') 
VALUES ('item','a','note to self')

这对我来说似乎很好.有什么问题吗?

which seems nice to me. What is the problem?

推荐答案

使用反引号`代替引号'来转义名称.引号是字符串定界符.

Use backticks ` instead of quotes ' to escape names. Quotes are string delimiters.

$toq="INSERT INTO articles (`word`,`group`, `selfnote`) VALUES ('$ttle','$wrdr','$snote')";

这篇关于MySQL错误-“您的SQL语法有错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆