htmlspecialchars and htmlentities not working?!

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
Donny Bahama
Forum Newbie
Posts: 18
Joined: Wed Mar 22, 2006 2:48 pm

htmlspecialchars and htmlentities not working?!

Post 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?
georgeoc
Forum Contributor
Posts: 166
Joined: Wed Aug 09, 2006 4:21 pm
Location: London, UK

Post 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'.
Donny Bahama
Forum Newbie
Posts: 18
Joined: Wed Mar 22, 2006 2:48 pm

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