在DB中插入标头值时出现MYSQL错误

时间:2014-03-09 19:52:52

标签: php mysql

我正在尝试将电子邮件的标头值插入到数据库中,但我收到以下提到的错误:    您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在'color:#1F497D'>附近使用正确的语法。 =

而保存此值的变量是:

$headerValue="x-store-info: J++/JTCzmObr++wNraA4Pa4f5Xd6uensVd8mvt5QRSOLhsGzuy+tUtmSAtwbT+Lhg32fI7JkT4T+oCCjUH2Po9WkZAzmMIYU0MxTJOx1JRLfrWSAJ4yq+QDUHkUMkOR6HLEpJj1jCGc=
Authentication-Results: hotmail.com; spf=neutral (sender IP is 66.39.4.58) smtp.mailfrom=xyz.abh@abc.in; dkim=none header.d=abc.in; x-hmca=none header.id=xyz.abh@abc.in
X-SID-PRA: xyz.abh@abc.in
X-AUTH-Result: NONE
X-SID-Result: NONE
X-Message-Status: n:n
X-Message-Delivery: Vj0xLjE7dXM9MDtsPTE7YT0xO0Q9MTtHRD0xO1NDTD0x
X-Message-Info: NhFq/7gR1vQP6lZqH93tpVQFT69R+Bmv3UykwdELmYZ7B3Xiq5XoKqM5Sg6LjXxhKff4sob+93uheSiXVqp/rY0haPrEn6zvVhDahXaFE0nw9nQNG7DoZ7tXJdlzLLUsiyHtmFWhLupgJOiCWx/N3LIzuBcoyXRyO+0UqhjFaJY+pNdDEFGjgVOsdbFgKDHkJCilkjEyMXrCtfvi6LQwqpvJ18a+yny6
Received: from mail1.g9.pair.com ([66.39.4.58]) by BAY0-MC2-F25.Bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4900);Sun, 9 Mar 2014 10:21:21 -0700
Received: from abccto (unknown [182.71.149.242])by mail1.g9.pair.com (Postfix) with ESMTPSA id 447B739863for <outloo1@outlook.com>; Sun, 9 Mar 2014 13:21:18 -0400 (EDT)
From: "xyz t" <xyz.dps@abc.in>
To: <outloo1@outlook.com>
Subject: This is test 1
Date: Sun, 9 Mar 2014 22:51:15 +0530
Message-ID: <001701cf3bbb$fc5a1940$f50e4bc0$@abc.in>
MIME-Version: 1.0
Content-Type: multipart/alternative;boundary="----=_NextPart_000_0018_01CF3BEA.16125540"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: Ac87u+X0jencwqnORxOvsW8e4oF0PQAAAYbQ
Content-Language: en-us
Return-Path: xyzt@abc.in
X-OriginalArrivalTime: 09 Mar 2014 17:21:21.0782 (UTC) FILETIME=[FDAB5160:01CF3BBB]


This is a multi-part message in MIME format.

------=_NextPart_000_0018_01CF3BEA.16125540
Content-Type: text/plain;charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi Freind 


------=_NextPart_000_0018_01CF3BEA.16125540
Content-Type: text/html;charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><META =
HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 12 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal{margin:0in;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink{mso-style-priority:99;color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed{mso-style-priority:99;color:purple;text-decoration:underline;}
span.EmailStyle17{mso-style-type:personal;font-family:"Calibri","sans-serif";color:windowtext;}
span.EmailStyle18{mso-style-type:personal-reply;font-family:"Calibri","sans-serif";color:#1F497D;}
.MsoChpDefault{mso-style-type:export-only;font-size:10.0pt;}
@page WordSection1{size:8.5in 11.0in;margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Hi =
xyz<span style=3D'color:#1F497D'> =
</span><o:p></o:p></p></div></body></html>
------=_NextPart_000_0018_01CF3BEA.16125540--"

我通过申请获得了这个价值:

$header = preg_replace('~[\r\n]+[ \t]+~', null, $obj_thang);
$header = preg_replace('~[ \t]+~', ' ', $header);

1 个答案:

答案 0 :(得分:2)

 1. string mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier = NULL ] )
 2. Escapes special characters in the unescaped_string, taking into
    account the current character set of the connection so that it is
    safe to place it in a mysql_query(). If binary data is to be
    inserted, this function must be used.
 3. mysql_real_escape_string() calls MySQL's library function
    mysql_real_escape_string, which prepends backslashes to the
    following characters: \x00, \n, \r, \, ', " and \x1a.
 4. This function must always (with few exceptions) be used to make data
    safe before sending a query to MySQL.
Further details are at -:
http://in3.php.net/mysql_real_escape_string