Problem with MySQL enconding

Problem with MySQL enconding

Posted by: realstat
Posted on: 2008-02-24 04:18:00

Hello,

I cannot get working my DB, so that russian letters are to be shown on site properly.

I have a feeling I missed some DB settings or set them incorrectly. Please, help!

Problem: Russian letters taken from DB are shown as question marks "??" on site. When I look at DB via phpmyadmin I can see them and they're ok, but on site they're just "????".
NOTE: Russian letters, output directly shown correctly, but once taken from DB they become broken.

What have I done:
1) I looked through the forum and I didn't find anything related to my problem.
2) I set collation to "cp1251_general_ci" to all the tables (which is Cyrillic, Windows, multilanguage, including Russian) in my DB.

What do I need:
1) To see correct Russian letters on site in cp1251 encoding
2) To be able to import text files with Russian letters in cp1251 encoding - I have already some.
3) To be able to manage DB via WEB. I have several admin scripts allowing the management of DB, but the result of their work is the same: I get the question marks as result.

Thanks in advance

Re: Problem with MySQL enconding

Posted by: modocharlie
Posted on: 2008-02-24 17:07:00

I'm way out of my league here but I could suggest you set all tables and the database itself to some sort of UTF encoding. (utf_general_ci works well with spanish special characters, it should work for cyrillic characters. If utf_general_ci doesn't work, choose a utf collation that suits your needs.)

keep in mind, no only the tables should be set to a specific collation. Also, the database itself should be set to use an appropriate encoding. Again, try a suitable utf8 encoding. To alter the database encoding, go to the "operations" tab after selecting your DB in phpmyadmin and change the collation accordingly

hope that helps a bit
cheers!


Re: Problem with MySQL enconding

Posted by: sXi
Posted on: 2008-02-24 23:46:00

utf8_unicode_ci



Re: Problem with MySQL enconding

Posted by: realstat
Posted on: 2008-02-25 01:52:00

I fixed this problem myself, and answering to my own post just in case anybody else will need the information.

NOTE: I do NOT need to move to utf8, I need to keep already existing encoding, so given solutions wouldn't work.

What I do is I run the query below immediately after connection to DB:
SET NAMES cp1251
and it works fine.

Re: Problem with MySQL enconding

Posted by: sXi
Posted on: 2008-02-26 17:42:00

Not good advice at all. If you retrace your steps you may realise your error.


The (default) MySQL settings:

MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation: utf8_unicode_ci

Handle import/export of practically all character sets. Russian included wink

Tags: question marksthanks in advancecollationphpmyadminquestion marksthanks in advancecollationphpmyadmin