Faced the problem of sampling data from the database when using the query with Russian letters.
There is a test database in the utf8_general_ci encoding, in it the table is also in the utf8_general_ci encoding. In table 2, the columns are eng and rus in which the data are:
eng rus GGGG ГГГГГ GGGG ГГГГ and there is php code
<?php $dbname = 'test'; $link = mysql_connect('localhost', 'root', 'password'); mysql_select_db($dbname,$link); if (!$link) { echo 'Ошибка подключения к mysql'; exit; } $sql = "SELECT count(*) from `test` WHERE `eng` like 'ГГ%'"; $res = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_row($res); $k_el = $row[0]; echo $k_el; ?> When using sql query
SELECT count(*) from `test` WHERE `eng` like 'ГГ%' Gives out: 0
When using the query
SELECT count(*) from `test` WHERE `eng` like 'GG%' Throws 2, as expected.
Those. There is no sampling on Russian letters from a DB.
If you make a database and tables in cp_1251_general_ci, then it gives an error
Illegal mix of collations (cp1251_general_ci, IMPLICIT) and
(latin1_swedish_ci, COERCIBLE) for operation 'like'
The problem is in the encoding, but how to fix it?