Basically on displaying data from MySQL database I have a htmlspecialchars()
function below that should convert single and double quotes to their safe entity(s). The problem I'm having is on viewing source code, it is only converting < > &
when I also need it to convert single and double quotes.
//sanitize data from db before displaying on webpage
function htmlsan($htmlsanitize){
return $htmlsanitize = htmlspecialchars($htmlsanitize, ENT_QUOTES, 'UTF-8');
}
Then when I want to use for example I do:
htmlsan($row['comment']);
Can someone tell me why it's not converting single and double quotes?
UPDATE
What's strange is htmlsan()
is used on comment in email and when I view source code of email it converts them, it seems that it won't convert the single/double quotes from the database on displaying on webpage. My database collation is also set to utf8_general_ci and I declare I am using utf8 on database connection etc.