Andy R
Andy R

Reputation: 379

MySQL output to PHP page showing a backslash

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

Upvotes: 0

Views: 47

Answers (2)

Andy Lester
Andy Lester

Reputation: 93676

Sounds like you have gpc_magic_quotes turned on.

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

Upvotes: 0

joaofgf
joaofgf

Reputation: 338

use stripslashes() to remove extra backslashes.

Upvotes: 1

Related Questions