Support » Fixing WordPress » newbie: mysql and utf-8

  • I am new to wordpress, mysql, php, etc., so sorry for not so clever question.

    As many others, I have a problem with some Eastern Europan characters in my backup copy – they don’t show up correctly. I have read about the problem in many forums. One piece of advice was to use a query
    mysql_query(“SET NAMES ‘utf8′”, $conn);

    The problem is that I don’t know where to put this query: which file, where exactly ,etc.? could anyone help me out?

    Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • thanks for the link

    unfortunately, this didn’t help
    mysql_query(“SET NAMES ‘utf8′”, $conn);
    it got worse, now ALL nonstandard characters became smth like Ä…Ä?ęėįšųūž

    maybe my provider’s mysql server is set incorrectly, i don’t know 🙁

    OK, let’s go back to the basics.
    Before the backup what was your character set (encoding)? Utf-8?
    What is the setting now?

    The only other “fix” I’ve found is this:
    a bit different from the previous one.

    What Eastern European language?

    thank you moshu for your attention, i got little bit nervous because of all this problem, so i had to eat a cake to calm down 🙂

    at least i got to the initial problem, at first I made a mistake and put in wp-db after line 43
    mysql_query(“SET NAMES ‘utf8′”);
    so everything got messed up but then I put
    mysql_query(“SET NAMES ‘utf8′”, $conn);
    and at least everything went back to normal EXCEPT TWO LETTERS. But I had the same situation before putting SET NAMES, so it didn’t help.

    OK I’ll try to explain but I have to say that this is not the problem in WordPress only, this is smth related to mysql encodings… I have the same problem with my Phorum program.

    I use UTF-8 everywhere in WordPress and I write it in the Lithuanian language:
    I didn’t notice anything wrong when writing posts, all the letters show up correctly, by the way, beside Latin letters Lithuanian has additional letters: ą?ęėįšųūž
    Problems arise when I try to restore posts, etc. from a backup copy and problems only with TWO letters “?” and capital “Š” – you cannot restore them; strange characters show up instead of them when restoring from a backup. You can see this in the first experimental post:

    I have read in forums that this happens with some characters, a bug in mysql or something. But all the guys say that SET NAMES in php code helps; in my case it made no difference though I tried to back through WordPress and through phpMyAdmin.

    Maybe there smth wrong when i open .sql backup file in editors like notepad but this is hardly a problem because only two letters are affected. Or maybe
    mysql_query(“SET NAMES ‘utf8′”, $conn);
    should be put in some other places in other files
    or maybe some other queries should be made
    I don’t know.

    OK. What you could try – because I see you are using WP 2.0.
    Try to delete/empty the folder called cache under wp-content (wp-content/cache)
    Maybe we are seeing an earlier cached version of the site.

    It is definitely a MySQL bug and the line
    mysql_query("SET NAMES 'utf8'");
    seemed to help others.
    (Even when this forum was moved at the end of last year, all the special characters in older posts are screwed up…)

    Try that cache thing.

    emptying cache didn’t help,
    well maybe i will find a solution one day 🙂

    It helped me to put:
    $this->query(‘SET NAMES UTF8’);
    in wp-db.php line 57 (just before the “$this->select($dbname);”).

    It’s a new site, though, so I’m not fully aware of the problems that could arise with the already-in-db texts.

    I’m a Lithuanian too, btw! =)



    When I placed the

    $this->query(‘SET NAMES UTF8’);

    line in wp-db.php, as above, all I got back was a database error, “no system variable NAMES”


    If you want UTF-8 support, you must use MySQL4.1 or later. The “SET NAMES” statement works as well with these versions.

    So close, our server has MySQL 4.0.26

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘newbie: mysql and utf-8’ is closed to new replies.