Wat i need to choose in sql db tabel "Collation"
to make posible to read russian letters
please help THX

8 Years
Discussion Span
Last Post by colweb

The Cyrillic character sets and collations are for use with Belarusian, Bulgarian, Russian, Ukrainian, and Serbian.
As soon as you connect to the database execute this:

mysql_query("SET NAMES CP1251");

And instead of ????? you get Russian characters (if they are in the database that is).

Edited by colweb: n/a


is not working with "cp1251_ukrainian_ci" :(

Edited by dan1992: n/a


is not working with "cp1251_ukrainian_ci" :(

No it isn't. It should be

mysql_query("SET NAMES CP1251");

. And if that doesn't work use

mysql_query("SET NAMES KOI8R");

. But remember to use it just after your php command where you connect to the database.

$get = mysql_query("SELECT *FROM menu ",$db);
	   while($row = mysql_fetch_assoc($get))

were in her ?


Сподіваюся, це пояснити, як це працює (Ukrainian - according to Google)
Надеюсь, это объяснить, как это работает (Russian)
Hopefully this explained how it works,

instead of using a special character set to handle Russian or Ukrainian you may want to have a look here: http://www.phpwact.org/php/i18n/charsets where they explain how things work and how you can avoid all problems by using utf-8.

But anyway, the mysql character set for Russian and Ukrainian are:
koi8r KOI8-R Relcom Russian
cp1251 Windows Cyrillic
koi8u KOI8-U Ukrainian
cp866 DOS Russian

To store non ASCII characters in a database column, you need to define that column with a specific character set. You can specify a character set at 3 levels: database, table, and column. For example:

   CREATE TABLE tbl_name (...) CHARACTER SET koi8u
   CREATE TABLE tbl_name (col_name CHAR(80) CHARACTER SET koi8u, ...)

Most problems come from the fact that the server is speaking in a different language than the client. To see what the server is using:

$db = mysql_connect('localhost');
echo  "Default settings...\n";
$get = mysql_query("SHOW VARIABLES LIKE 'character_set_%'");
while ($row = mysql_fetch_array($get)) {
    echo "    ".$row[0].'   '.$row[1]."\n";

To change the way you communicate with the server you need to use "SET NAMES 'x'". This command is equivalent to these three statements:
SET character_set_client = x;
SET character_set_results = x;
SET character_set_connection = x;

And doing it in php:

$db = mysql_connect('localhost');
// change character set to Ukrainian
$get = mysql_query("SET NAMES 'koi8u'");
// now we can do our select, insert and so on.
$get = mysql_query("SELECT * FROM menu ",$db);
while($row = mysql_fetch_assoc($get)) {

thx thery much

Only trying to be helpful. If my last reply did solve your problem, could you please mark this thread as solved then. Thank you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.