Page 1 of 1

Problem with character like ' " /

Posted: Tue Mar 24, 2009 12:03 pm
by loonyew
Hi there, need help on this....TQ very much

The character ' is giving me problem on this

<textarea name="message"></textarea>

whenever i submit the textarea and i echo back the contents


Customer's Name is Johnson

will become

Customer\'s Name is Johnson


That is "abc"

will become

That is \"abc\"


You can choose either\

will become

You can choose either\\

tried with
echo $_Request[ 'message' ] --->produce the red result

$temp = $_Request[ 'message' ];
echo $temp --->produce the red result

Re: Problem with character like ' " /

Posted: Tue Mar 24, 2009 12:23 pm
by wellhole
try echo "$temp"

Re: Problem with character like ' " /

Posted: Tue Mar 24, 2009 3:37 pm
by requinix
Won't help in the least bit.

It's called magic quotes. With this INI setting on, PHP automatically runs addslashes on all input, which escapes things like quotes and backslashes.

Turn it off in php.ini, in a .htaccess with

Code: Select all

php_flag magic_quotes_gpc off
or, as a last resort if you can't do either, run everything through stripslashes before trying to use it, like

Code: Select all

echo stripslashes($_Request['message']);

Re: Problem with character like ' " /

Posted: Wed Mar 25, 2009 8:51 am
by loonyew
Thank for the reply...got the solutions something like tasairis

if(get_magic_quotes_gpc()){ //check wheher the mgic quotes gpc is tunrned on

$message=stripslashes($_REQUEST[ 'txtMessage' ]);

}else{
//magic quotes gpc is turned off....so not need use stripslashes
$message=$_REQUEST[ 'txtMessage' ];

}