2014-06-25 19:39



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 ;-)

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


  • doucan8521 doucan8521 7年前

    Sounds like you have gpc_magic_quotes turned on.

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

    use stripslashes() to remove extra backslashes.

    点赞 评论 复制链接分享