I am pulling comments out of the database and have this, �, show up… how do I get rid of it? Is it because of whats in the database or how I’m showing it, I’ve tried using htmlspecialchars but doesn’t work.
Please help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem lies with Character Encoding. If the character shows up fine in the database, but not on the page. Your page needs to be set to the same character encoding as the database. And vice a versa, if your page that posts to the database character encoding does not match, well it comes out weird.
I generally set my character encoding to UTF-8 for any type of posting fields, such as Comments / Posts. Most MySQL databases default to the latin charset. So you will need to modify that: http://yoonkit.blogspot.com/2006/03/mysql-charset-from-latin1-to-utf8.html
The HTML part can be done with a
METAtag:<META http-equiv="Content-Type" content="text/html; charset=UTF-8">or with PHP:
header('Content-type: text/html; charset=utf-8');(must be placed before any output.)Hopefully that gets the ball rolling for you.