phpmyadmin + php in Russian

In phpmyadmin I have stored a few russian values, using utf8_unicode_ci encoding. They are shown perfectly in phpmyadmin.

The problem appears when I get those values with php and I try to put them into options of a select, they are shown as "??????".

I've tried changing the encoding in the headers to iso-8859-1 instead of utf-8 but it doesn't work neither.

I've also tried with

mb_convert_encoding($str, 'UTF-8', 'auto');

but no change :(

Any other idea??

If you're using a MySQL DB/connection, use mysql_query("SET NAMES 'utf8'"); before your run your query, though a better alternative is mysql_set_charset().

Also ensure you have the entry:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

In the header section of your page.

If you're using PDO, change your connection to:

$PDO_connection = new PDO("mysql:host=".$db['host'].";dbname=".$db['name'],
$db['user'], $db['pword'],
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")

I've tried changing the encoding in the headers to iso-8859-1 instead of utf-8

What for? what's the point in changing right encoding that support russian characters to wrong one that doesn't?

In order to achieve proper encoding on your page, you u have to do 2 things:

  1. To tell the database what encoding you're expecting your data in. It should be done with mysql_set_charset('utf8') (or similar function of other library if you'r using one) where utf8 is the name of the encoding in mysql lingo.
  2. to tell a browser what encoding your page in. it should be done with Content-type HTTP header, using header ('Content-type: text/html; charset=utf-8'); and nothing else.