Today, mysql_real_escape_string() is escaping single quotes AND double quotes

前端 未结 2 656
孤街浪徒
孤街浪徒 2021-01-20 01:47
$str = \'BEGIN This is a \"quote\" test. \\\'Single\\\' END\';
echo $str . \"\\n\";
echo mysql_real_escape_string($str);

// Outputs:
BEGIN This is a \"quote\" test.         


        
相关标签:
2条回答
  • 2021-01-20 02:17

    Sounds like magic quotes got turned on.

    This post details your problem exactly, along with fixes. http://www.sitepoint.com/forums/showthread.php?t=545824

    0 讨论(0)
  • 2021-01-20 02:36

    " does start a string in MySQL. (See: Strings)

    Exception:

    If the ANSI_QUOTES SQL mode is enabled, string literals can be quoted only within single quotation marks because a string quoted within double quotation marks is interpreted as an identifier.

    0 讨论(0)
提交回复
热议问题