$_POST returns \" instead of "

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Murble
Forum Newbie
Posts: 11
Joined: Thu Feb 10, 2005 3:27 am

$_POST returns \" instead of "

Post 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.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: $_POST returns \" instead of "

Post by jayshields »

stripslashes()
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: $_POST returns \" instead of "

Post by papa »

You can play around with this: stripslashes
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: $_POST returns \" instead of "

Post by Benjamin »

:arrow: Moved to PHP - Code
Murble
Forum Newbie
Posts: 11
Joined: Thu Feb 10, 2005 3:27 am

Re: $_POST returns \" instead of "

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: $_POST returns \" instead of "

Post by jayshields »

nl2br()
Murble
Forum Newbie
Posts: 11
Joined: Thu Feb 10, 2005 3:27 am

Re: $_POST returns \" instead of "

Post 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?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: $_POST returns \" instead of "

Post by Bill H »

Use nl2br() first and then stripslashes().
Forget preg_replace() and str_replace().

$content = stripslashes (nl2br($content));
danielrs1
Forum Commoner
Posts: 29
Joined: Wed Jun 24, 2009 5:30 pm

Re: $_POST returns \" instead of "

Post by danielrs1 »

Maybe you have magic_quotes active, you should disable it.
Murble
Forum Newbie
Posts: 11
Joined: Thu Feb 10, 2005 3:27 am

Re: $_POST returns \" instead of "

Post by Murble »

what is that and how do I do it?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: $_POST returns \" instead of "

Post by pickle »

Google has lots of information on magic quotes & how to deal with them.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: $_POST returns \" instead of "

Post 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.
Post Reply