MySQL INSERT INTO语法错误1064

时间:2012-07-09 20:48:02

标签: mysql mysqli syntax-error insert-into

很抱歉,我的MySQL语句再次出现语法错误!我很确定它是JSON,但我使用mysqli_real_escape_string来逃避它,虽然这可能还不够?

以下是我的发言:

INSERT INTO emails (attachments, cc, cc_full, date, from, headers, html_body, mailbox_hash, message_id, reply_to, send_date, subject, tag, text_body, to, to_full) VALUES ([{\"Content\":\"VGhpcyBpcyBhdHRhY2htZW50IGNvbnRlbnRzLCBiYXNlLTY0IGVuY29kZWQu\",\"ContentLength\":60,\"ContentType\":\"text\/plain\",\"Name\":\"test.txt\"}], \"First Cc\" , secondCc@postmarkapp.com, [{\"Email\":\"firstcc@postmarkapp.com\",\"Name\":\"First Cc\"},{\"Email\":\"secondCc@postmarkapp.com\"}], Mon, 5 Mar 2012 14:33:50 +0100, support@postmarkapp.com, [{\"Name\":\"X-Header-Test\",\"Value\":\"\"}],

from

to

我收到此错误:

This is a test html body.

我真的希望有人可以提供帮助!我也非常感谢我在哪里出错了,所以下次我知道!谢谢大家,非常感谢:)

1 个答案:

答案 0 :(得分:0)

每个值都应该用引号括起来,就像:

INSERT INTO emails (attachments, cc, cc_full, date, from, headers, html_body, mailbox_hash, message_id, reply_to, send_date, subject, tag, text_body, to, to_full) VALUES ("[{\"Content\":\"VGhpcyBpcyBhdHRhY2htZW50IGNvbnRlbnRzLCBiYXNlLTY0IGVuY29kZWQu\",\"ContentLength\":60,\"ContentType\":\"text\/plain\",\"Name\":\"test.txt\"}]", "\"First Cc\" , secondCc@postmarkapp.com", "[{\"Email\":\"firstcc@postmarkapp.com\",\"Name\":\"First Cc\"},{\"Email\":\"secondCc@postmarkapp.com\"}]", "Mon, 5 Mar 2012 14:33:50 +0100", "support@postmarkapp.com", "[{\"Name\":\"X-Header-Test\",\"Value\":\"\"}]", " This is a test html body.

from

to

然后,它也会在值内查看逗号。

全部谢谢!