【发布时间】:2013-06-23 19:28:26
【问题描述】:
我的代码在插入数据库的代码行中抛出错误Error in mysql syntax。当我回显插入时,我得到 p>
INSERT INTO patches (
name,
description,
type,
com1,
com2,
com1,
code,
db,
other,
tfsID,
release,
createdBy,
createdDtTm,
updatedBy,
updatedDtTm
) VALUES (
'testPatch2',
'longPatchDescription',
'Code - Full Build',
'0',
'1',
'1',
'0',
'1',
'1',
'98765',
'6.11.0',
'mhopkins',
'2013/06/26 08:58:19',
'mhopkins',
'2013/06/26 08:58:19'
)
我相信我的语法没问题。但我很困惑为什么我无法获得更多关于错误的数据。想法?
准确的错误
Errormessage: 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 'release, createdBy, createdDtTm, updatedBy, updatedDtTm) VALUES ('testPatch2','l' at line 1
【问题讨论】:
-
你能添加确切的错误吗?我建议您可能使用 SQL 保留字作为列名,您可以通过在每列周围使用反引号来绕过它。
-
MySQL 生成更详细的错误消息。您使用的任何工具都是释义。直接对 MySQL 运行查询。
-
发布表的创建表,以便我们可以看到列类型,但快速猜测我会说所有这些数字都应该是 1 而不是 '1'
-
添加了确切的错误。我在 mysql workbench 中运行查询并得到相同的文本
-
@mhopkins321 -
release确实是保留字,所以用反引号括起来。尽管您应该考虑尽可能重命名该字段。
标签: php mysql insert mysqli syntax-error