开发者

After mysql_real_escape_string, apostrophes showing up in Twitter with a preceding backslash

In the code below, the second line posts $comment to Twitter.

Wh开发者_如何学Pythonen $comment below has apostrophes in it, they are preceded in the Tweet with a backslash. How can I get rid of the backslash in Twitter?

$comment = mysql_real_escape_string($_POST['comment']);

$tweet->post("statuses/update", array("status" => "$comment $fullurl"));


There's no SQL visible in all of this, so there is no point in calling mysql_real_escape_string. In fact, since you say you're posting to Twitter, I doubt there's any SQL involved at all on your side (at least not for that part).

Escaping should always be done as the very last thing, immediately before actually using the variable in an SQL statement, and only for the context of that SQL statement. If your $tweet->post function does some SQL on your side as well, have that function do the escaping necessary.


Perhaps magic_quotes are set to on in PHP conf? See manual

You can do also

$comment = mysql_real_escape_string(stripslashes($_POST['comment']));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜