douxian9706
douxian9706
2014-06-25 19:39

MySQL输出到PHP页面显示反斜杠

已采纳

I have a form that asks for a name. The php to process it is:

$name = mysqli_real_escape_string($dbc, trim($_POST['name']));

When someone inserts a name with an apostrophe e.g. Dan O'Shea it shows up in the mysql database fine, but on the webpage it's output shows up as Dan O\Shea.

How do I get rid of the \ backslash and show the ' apostrophe on the webpage? Can I use str_replace('/','', $string) with mysqli_real_escape_string, and if so how?

Thanks for any help,

Andy ;-)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • doucan8521 doucan8521 7年前

    Sounds like you have gpc_magic_quotes turned on.

    http://php.net/manual/en/security.magicquotes.php

    点赞 评论 复制链接分享
  • dqm83011 dqm83011 7年前

    use stripslashes() to remove extra backslashes.

    点赞 评论 复制链接分享