Page 1 of 1

$_POST returns \" instead of "

Posted: Tue Jun 23, 2009 5:16 am
by Murble
Hello

When I receive a variable from the FORM page,

text that includes a
"
character,
arrives as
\"

or for a second example

'
arrives as
\'


what should I do?

thank you
Chag.

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 6:07 am
by jayshields
stripslashes()

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 6:08 am
by papa
You can play around with this: stripslashes

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 10:02 am
by Benjamin
:arrow: Moved to PHP - Code

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 11:53 am
by Murble
I am now using WYSIWYG-Editor

but when I load the text from file it returns \n
when I replace them with <br> it still show n on the screen

anyone knows why?

I tryed:


$content = addslashes(preg_replace('`[\r\n]`','\n',$content));
$content = stripslashes ($content);
$content = str_replace("\n", "<br>", $content);


in all kind of orders.
still, instead on <BR> it shows "n" on the screen

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 2:05 pm
by jayshields
nl2br()

Re: $_POST returns \" instead of "

Posted: Tue Jun 23, 2009 2:41 pm
by Murble
this also doesn't work.

the only one that work is the stripslashes

and because the string arrives with \n

the output shows the letter n bacause it removed the \

can I send someone the code?

Re: $_POST returns \" instead of "

Posted: Fri Jun 26, 2009 11:17 am
by Bill H
Use nl2br() first and then stripslashes().
Forget preg_replace() and str_replace().

$content = stripslashes (nl2br($content));

Re: $_POST returns \" instead of "

Posted: Fri Jun 26, 2009 12:51 pm
by danielrs1
Maybe you have magic_quotes active, you should disable it.

Re: $_POST returns \" instead of "

Posted: Fri Jun 26, 2009 1:21 pm
by Murble
what is that and how do I do it?

Re: $_POST returns \" instead of "

Posted: Fri Jun 26, 2009 2:03 pm
by pickle
Google has lots of information on magic quotes & how to deal with them.

Re: $_POST returns \" instead of "

Posted: Fri Jun 26, 2009 3:34 pm
by Bill H
I agree that magic_quotes should be disabled, but $content = stripslashes(nl2br($content)); will function correctly whether they are on or not.