There is a database encoded utf8_ general_ci. There is a request to output data from the table. If necessary, here it is below:

<?php $query = "SELECT `shoutbox`.id AS id,`shoutbox`.date AS date,`shoutbox`.user AS user,`shoutbox`.message AS message FROM `shoutbox` ORDER BY `shoutbox`.id DESC;"; $mysql_result = mysql_query ($query); ?> <table id="reviews_table" border="0"> <?php $class_num = 2; while($row = mysql_fetch_array ($mysql_result)) { $class_num = 3 - $class_num;?> <tr> <td> </td> <td width="90px"> <span class="date"><?php echo htmlspecialchars($row["user"]); ?></span> </td> <td> <font class="faq_text"><?php echo htmlspecialchars($row["message"]); ?> </font> </td> </tr> <?php } ?> </table> 

Instead of Russian letters is displayed ??? ? ???? ? ? ? ?

How to fix where to dig?

I tried to write

 header("Content-Type: text/html; charset=UTF-8"); iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "Windows-1251"); ob_start("ob_iconv_handler"); 

Did not help

  • If I were paid one cent for each answer on this topic, then I would have been a millionaire)) Headers are good, iconv is bad, but check that the documents were saved in UTF-8 without BOM, make sure that the comparison For the text fields of the form, utf8_general_ci is compared, after connecting to the database, make a request: SET NAMES utf8 In htaccess, set the line: AddDefaultCharset UTF-8 - Deonis
  • Some tables in 1251, I need to display on one page only in utf-8. Therefore, htaccess does not change the version of mysql_query ("SET NAMES 'utf8'"); mysql_query ("SET CHARACTER SET 'utf8'"); Prescribed it, scribbles became zagagulinam type of the order of the word! Ð - Rammsteinik
  • @Rammsteinik, now try removing iconv - etki
  • It did not help - Rammsteinik

2 answers 2

First use the @Rammsteinik comment

 mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER SET 'utf8'"); 

And then the answer is @lopar

 <meta charset="UTF-8" /> 

All this should give you the desired result)

And just in case somewhere in php: setlocale (LC_CTYPE, "ru_RU.UTF-8");

    Check that this page is available:

    1. <meta charset="UTF-8" />
    2. The page itself is saved in UTF-8 encoding. Text file with code.