Hello, there is a sql table of news , when I add news with Russian letters, in response I get these characters:

????????????????? ???????????????? ???

And with English letters, everything is fine. What could it be? Site encoding charset=windows-1251 .

  • DB data encoding is what? - Fucking Babai
  • utf8_general_ci, changed to 1251 did not work, and returned to the previous encoding (utf8_general_ci) - Maksoud
  • one
    In addition to the database encoding, there is also a table coding, as far as I remember - there is even a coding of table fields. In general, a question of this nature has been repeatedly discussed on the Internet, incl. here. Each time the vehicle thought that it was special and something else did not work for it (differently, etc., etc.), although perhaps it was stupid for him to understand, but that’s not the point. The bottom line is that you will not see anything new, and if the simplest options have not saved you - most likely you will have to figure it out anyway, whether you like it or not. (PS: if you're new - it changes absolutely nothing) - Zowie
  • AlexWindHope, thanks, after reading your comment, I checked and changed all encodings of tables and fields, now everything works fine! Thank you - Maxoud
  • @Maksoud - congratulations, you are not hopeless: D - Zowie

5 answers 5

Try to do before database queries.

 mysql_query("SET NAMES 'cp1251'"); 
  • Put, without changes, and for one checked phpmyadmin, there are also in the title cell the same characters as above - Maxoud
  • In the table I just noticed that where the "Comparison" there stands the encoding: latin1_swedish_ci, how to change it? - Maxoud

If it is MS SQL Server, then you need to set the connection language. SET LANGUAGE 'Russian'

  • This is MySql, hosted by IpiHoster. - Maxoud
  • C MySql is not familiar, but if it helps. In MS SQL, all regional parameters (language, date, etc., are set only for the current connection - SET LANGUAGE 'Russian') - Oleg53

From the fact that you changed the encoding in the table, the encoding of the strings does not change, now you need to convert all the strings to the desired encoding. For a better understanding of the topic - Encodings in MySQL

    .htaccess, AddDefaulCharset cp1251

    • Internal Server Error, this is most likely to be corrected in phpmyadmin, because even if you change the news table (text), you still see the following symbols: ???????????? - Maxoud
    • in the Firefox browser, check Menu-> View-> Encoding-> Try different encodings to put, does the characters ??????? disappear, if so, at what encoding? Etc. I think your encoding is all right, only the data in the database is not stored in that encoding. - Vfvtnjd
    • Data in the database? Where to check it? And it makes no sense to check the page encoding through the browser, since php receives such characters from the database. If I'm wrong, then correct me. - Maxoud

    Try the file itself in which the connection to the database is registered to convert to UTF - 8 without BOM. Also check the encoding of the fields themselves in the database.

    Added.

    Try this:

     $conn = mysql_connect("localhost", "db_user", "xxxxxxxx") or die("Ошибка при подключении к хосту" . mysql_error()); mysql_select_db("db_name", $conn) or die ("Нет такой схемы" . mysql_error()); mysql_query ("SET NAMES 'CP1251'"); // устанавливаем кодировку для страницы 

    You can even try this:

     mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $conn); 
    • Did not help: ( - Maksoud
    • Try this: $ conn = mysql_connect ("localhost", "db_user", "xxxxxxxx") or die ("Error connecting to host". Mysql_error ()); mysql_select_db ("db_name", $ conn) or die ("There is no such scheme." mysql_error ()); mysql_query ("SET NAMES 'CP1251'"); // set the coding for the page ; - archisova