$_POST returns \" instead of "
Moderator: General Moderators
$_POST returns \" instead of "
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.
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.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: $_POST returns \" instead of "
stripslashes()
Re: $_POST returns \" instead of "
You can play around with this: stripslashes
Re: $_POST returns \" instead of "
Re: $_POST returns \" instead of "
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
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
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: $_POST returns \" instead of "
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?
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?
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: $_POST returns \" instead of "
Use nl2br() first and then stripslashes().
Forget preg_replace() and str_replace().
$content = stripslashes (nl2br($content));
Forget preg_replace() and str_replace().
$content = stripslashes (nl2br($content));
Re: $_POST returns \" instead of "
Maybe you have magic_quotes active, you should disable it.
Re: $_POST returns \" instead of "
what is that and how do I do it?
Re: $_POST returns \" instead of "
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.
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: $_POST returns \" instead of "
I agree that magic_quotes should be disabled, but $content = stripslashes(nl2br($content)); will function correctly whether they are on or not.