Jump to content

random symobols printed in html output


AdRock

Recommended Posts

I have noticed that today that some of the content that is saved from my form is printing random characters and crap.

 

I am using htmlentities on the form input and it seems to be adding more rubbish.

 

I am using the UTF-8 charset as a meta tag.

 

Is this the correct way of using htmlentities?

 

htmlentities($string,  ENT_QUOTES, 'UTF-8')

 

Also i noticed the other day with a problem I had that using htmlentities was replacing " with &" when i thought it should have just been "

Link to comment
https://forums.phpfreaks.com/topic/210590-random-symobols-printed-in-html-output/
Share on other sites

Make sure you use htmlentities() only once.  If you use it more than once on the same data, it will get corrupted.

 

I'm not sure from the post if you are clear on this, but htmlentities() is to encode data for inserting into the html output from your script.  It shouldn't be applied to input coming from a form, in usual circumstances.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.