Good day! There is the following site http://integral.besaba.com/index.php

There was a problem with the encoding: the text from the database is displayed incorrectly. What could be the problem? Throw sentences. Encoding in the database is utf8_general_ci . Help me please.

  • Do you, I hope, correctly convert data when reading from a database / when outputting it to a page? You know about each line in your code, in what encoding is it? (And if not, why not?) - VladD
  • For the sake of interest, try to make a utf-8 encoding without a BOM in one of the source files (for example, notepad ++). Is the site in PHP? - ghost rider
  • VladD, I do not know about the string variable. Where to look for it? - IntegralAL
  • ghost rider, site in php. Right. - IntegralAL
  • ghost rider, did not help. Same nonsense. - IntegralAL

1 answer 1

Not at all strange. The site is given in windows-1251 encoding. The menu is also in this encoding, because displayed normally. The data from the database comes in utf-8 and is displayed clumsily.

Set the page encoding to utf-8 and save the site pages in the same encoding, or convert the output from the database to windows-1251 .

For PHP info here: iconv ()

  • Exposing the page encoding depending on the encoding of the base is non-kosher: it is not the business of the database to determine in which encoding I send the document. But to convert the data from the database to the desired encoding after reading is a good idea. - VladD
  • thanks, I will move in this direction ... - IntegralAL
  • the question is, why on Denver (on the local machine) everything was correctly reflected, and here it was so clumsy? - IntegralAL
  • @VladD, I agree. The first version is written for the case for people who think that by setting the base encoding in UTF-8 they will receive the site in UTF-8 . @IntegralAL, this is no longer important. Somehow it worked - maybe your files were in a different encoding there, maybe the server gave a different encoding, maybe the base was in a different encoding. Maybe .. - xEdelweiss
  • Well, thanks, I did everything ... you can admire)) on the site. - IntegralAL