php / mysql / html5 and charset...

ok.  I give in.

I have tried for ages, but can't solve this, I know there is going to be a simple solution - don't let me down experts.

I build content managed websites using php and mysql.  I also use the webassist HTMLEditor pluging as my HTML editor of choice.

Recently I upgraded to HTMLEditor 3 and roughly at the same time, started using HTML5 (loving the curvy corners and wonky boxes), but I'm having an impossible issue with my charset and the content managed data...

The text that I edit/create using the HTML editor gives me <?> (black diamond with question mark) characters instead of £ (pound sugns) when it displays.

I am using the <meta charset=utf-8 /> as my charset definition. (tried all sorts of variations)

Here's the issue.  If I type '£' into my document source, it renders as a £, but any £ entered via the HTML editor render as <?>.  Using phpmyadmin to check what's being saved shows me a £.

I can't see any encoding settings on the webassist htmleditor, on file, it looks fine, entering £ into the source file works fine, but the stuff stored in MySQL, pulled in via PHP and 'echo'ed doesn't work...

Please help, someone.  Been going on too long, so max points for a quick solution.

Got a client meeting in 10 hours, can anyone resolve?

Who is Participating?
Lukasz ChmielewskiCommented:
Try to put this
    mysql_query("SET NAMES 'utf8'");
just after you connect to the database. Maybe I misunderstood something, but is the pound sign visible in the database or it is put in the database as a black diamond ? Check your file charset encoding also.
CrisThompsonUKAuthor Commented:
going to bed now, so won't be able to post any more replies for 8 hours or so...
Erdinç Güngör ÇorbacıPHP Development Team LeaderCommented:
Are your mysql db and table and field's encoding utf8 and collations are utf8_general if not try converting them.
You can also solve this with iconv from php side.
look at sample taken from below

$text = "This is the Euro symbol '€'.";

echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;


Open in new window

You can find details here ;

Good luck
CrisThompsonUKAuthor Commented:
CrisThompsonUKAuthor Commented:
Just to keep this answer complete, this fix worked for one of my sites, but not for another until I changed the MySQL data type from BLOG to TEXT...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.