php / mysql / html5 and charset...

Posted on 2011-05-05
Last Modified: 2012-08-13
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?

Question by:CrisThompsonUK

    Author Comment

    going to bed now, so won't be able to post any more replies for 8 hours or so...
    LVL 9

    Expert Comment

    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
    LVL 27

    Accepted Solution

    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.

    Author Closing Comment


    Author Comment

    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...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now