Skip to content Skip to sidebar Skip to footer

Php: Getting "ssa's" Instead Of "ssa's"

Im having a problem displaying certain data with PHP from the database. How its currently showing - 'SSA's' How it should show 'SSA's' HTML Meta Tag meta charset='UTF-8'&g

Solution 1:

You can decode by using these two methods html_entity_decode() or htmlspecialchars_decode()

Basic Example:

$string = html_entity_decode("SSA's");
echo$string; // result SSA's$string = htmlspecialchars_decode("SSA's");
echo$string; // result SSA's

Solution 2:

Remove the html_entity_decode function, as you are double encoding HTML-ENTITIES

And as @ChrisBanks pointed out, you also don't need stripslashes

Solution 3:

You need to call html_entity_decode again because the data is being stored as double encoded and remove the stripslashes.

$article_title = html_entity_decode(html_entity_decode(mb_convert_encoding($r->ArticleTitle, "HTML-ENTITIES", 'UTF-8')));

You might want to investigate how the data is being stored in the database as double-encoded in the first place. Perhaps htmlentities is being called twice somewhere.

To add on to the comment:

You shouldn't store data HTML encoded unless for some reason you really and truly need to (there might be some cases you're required to). It is only on output and rendering on a webpage do you want to use htmlentities.

Post a Comment for "Php: Getting "ssa's" Instead Of "ssa's""