也许这是我的疑问,但我不这么认为。我正在尝试将从mbox格式解析的消息导入MySQL,但是当我通过PHP或通过phpMyAdmin手动执行时,MySQL会失败。有什么想法吗?
$sql='INSERT INTO `listserv_mbox` ("message-id", "mbox")
VALUES ("'.mysql_real_escape_string($structure->headers['message-id']).'"
,"'.mysql_real_escape_string($message_base64).'")';
// Run our MySQL query
$db->Execute($sql);
这段代码看起来对我来说是正确的,所以我完全迷失了为什么我无法以任何理由导入这些数据。我一直得到的错误是:
1064:您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'“message-id”,“mbox”附近使用正确的语法)VALUES(“&lt; 012c01c69c88 $ 98e38250 $ 31780b4b @ dtadavid&gt;”,“RnJvb'在第1行< / p>
查询如下所示。我以前无法让它工作,所以我决定在消息本身上尝试base64_encode(),但它仍然不起作用。这是base64_encod()'查询。
INSERT INTO `listserv_mbox` ("message-id", "mbox")
VALUES ("<012c01c69c88$98e38250$31780b4b@dtadavid>"
,"RnJvbSBkYXZpZC53YWxsaXNAZHRhaG91LmNvbSBGcmkgSnVuIDMwIDE1OjA3OjQyIDIwMDYKUmVjZWl2ZWQ6IGZyb20gbWFpbC5kdGFob3UuY29tIChtYWlsLmR0YWhvdS5jb20gWzY1LjM4LjExMC4yMjFdKQoJYnkgbG9jYWxob3N0LmxvY2FsZG9tYWluICg4LjEyLjgvOC4xMi44KSB3aXRoIEVTTVRQIGlkIGs1VUs3Z1h1MDIyMTEwCglmb3IgPGFwZGYtZGlzY3Vzc2lvbnNAbGlzdHMuYWFwZGYub3JnPjsKCUZyaSwgMzAgSnVuIDIwMDYgMTU6MDc6NDIgLTA1MDAKeC1maWx0ZXJlZDogMQpSZWNlaXZlZDogZnJvbSBsb2NhbC1pcFt4LngueC54XSBieSBtYWlsMS5kdGFob3UubG9jYWw7CiAgICAgRnJpLCAzMCBKdW4gMjAwNiAxNjowNDo0NCAtMDUwMApNZXNzYWdlLUlEOiA8MDEyYzAxYzY5Yzg4JDk4ZTM4MjUwJDMxN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RlbnQ9M0QidGV4dC9odG1sOyA9CmNoYXJzZXQ9M0Rpc28tODg1OS0xIj4KPE1FVEEgY29udGVudD0zRCJNU0hUTUwgNi4wMC4yOTAwLjI5MTIiIG5hbWU9M0RHRU5FUkFUT1I+CjxTVFlMRT48L1NUWUxFPgo8L0hFQUQ+CjxCT0RZIGJnQ29sb3I9M0QjZmZmZmZmPgo8RElWPjxGT05UIGZhY2U9M0RBcmlhbCBzaXplPTNEMj50aGlzIGlzIGEgPQp0ZXN0PC9GT05UPjwvRElWPjwvQk9EWT48L0hUTUw+CgotLS0tLS09X05leHRQYXJ0XzAwMF8wMTI5XzAxQzY5QzVFLkFGRjA3QzcwLS0=")
答案 0 :(得分:2)
INSERT INTO `listserv_mbox` ("message-id", "mbox"
那应该是
INSERT INTO `listserv_mbox` (`message-id`, `mbox`
`
代替"
答案 1 :(得分:0)
对于字段类型“message_id”而言,可能值太长了