Page 1 of 1

htmlspecialchars and htmlentities not working?!

Posted: Thu May 17, 2007 3:26 pm
by Donny Bahama
Using a form to post this string: aaa "bbb" ccc 'ddd' eee
This code:

Code: Select all

$postmsg=$_POST['postmsg'];
	echo $bdo."Before htmlentities, postmsg='$postmsg'.".$edo;
	$postmsg=htmlentities($postmsg, ENT_QUOTES);
	echo $bdo."After htmlentities, postmsg='$postmsg'.".$edo;
returns After htmlentities, postmsg='aaa "bbb" ccc 'ddd' eee'.

I get the exact same results with htmlspecialchars. Any suggestions?

Posted: Thu May 17, 2007 6:18 pm
by georgeoc
Have you tried viewing the source of the printed text? You'll see:

Code: Select all

After htmlentities, postmsg='aaa "bbb" ccc 'ddd' eee'.
in the browser, but the source code is:

Code: Select all

After htmlentities, postmsg='aaa "bbb" ccc 'ddd' eee'.

Posted: Fri May 18, 2007 10:07 am
by Donny Bahama
OMG!I am such a f'ing IDIOT!!!

Thanks, George! Sometimes I guess it's hard to see the forest for all those trees!