I'm reading from a UTF8 rss feed to a php script using simplexml_load_file. The title is then inserted into a mysql database that has charset set as UTF8 - general. It is then selected by another php page which outputs to UTF8 html however some of my characters are being stored wrong .. For Example a normal hyphen - will be displayed as – What's the best way to go about fixing this issue? I've tried changing it all to other Charsets and using utf_decode() but not luck?
Hi, You have two SQL connections here, make sure they use UTF8 charset, the first is when you write the title to MySQL, and the second is when you read them back, in both cases, make sure to issue "SET NAMES utf8;" Code (markup): MySQL query after you connect to MySQL, this will set the character set along the connected session.
<?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_set_charset('utf8', $link); //add this after you connect PHP: