Hi
I am having problems with htmlentitites() and am hoping someone can offer me advice.
Basically, I'm developing an application to take mySQL data and present it on a web page using a table, the problem I have is with converting special characters such as a quote to their ASCII equivalent. The data looks fine on the web but it isn't valid XHTML because it doesn't use proper ASCII codes.
Example: Don't order with this supplier
Should be translated to: Don't order with this supplier
I've tried using htmlentities but it doesn't make any difference.
The code I'm using is htmlentities($row['suppliercomments'], ENT_QUOTES)
Does anyone have any advice?
Thanks
htmlentities()
Moderator: General Moderators
It will convert it, but your browser will display it as a single quote.
Turns into:
Don't order with this supplier<br />
Don't order with this supplier
Code: Select all
<?PHP
$original = "Don't order with this supplier";
echo($original . '<br />' .
htmlentities($original,ENT_QUOTES));
?>Don't order with this supplier<br />
Don't order with this supplier
Hisomeberry wrote:It will convert it, but your browser will display it as a single quote.
Turns into:Code: Select all
<?PHP $original = "Don't order with this supplier"; echo($original . '<br />' . htmlentities($original,ENT_QUOTES)); ?>
Don't order with this supplier<br />
Don't order with this supplier
Thanks for your quick response.
I see the logic in the above example and it correctly displays a single quote and if you view the HTML source you can see that the ascii code has been inserted properly.
The problem is that this does not work for data from a database. e.g. htmlentities($row['supplier'],ENT_QUOTES)
Maybe I am missing something!