The question is closed. Everything was decided in one line:

header ('Content-type: text/html; charset=utf-8'); 

The fact is that there are no "cracks" on the page, but there is a mess in the sql table. Not just question marks or the like, but real kryakozyabry. But this applies only to Russian letters.

On sql installed utf8_general_ci.

Of course I tried some other images to change the encoding to utf-8, but to no avail. Help me please

  • when you connect to the database you expose encoding in the session, - Mike
  • What are you looking at in sql with cracks? - Visman Nov.
  • What encoding is set for the page - meta charset? - Sergey Moiseenko
  • You do not see what is happening in the table. In principle, if, of course, you do not look at the table files, bypassing the server, directly in the file system. You see data that has undergone at least two processing - between the server and the access driver, and between the driver and the client program. Well, in principle, even when the client was on the screen, he could have podshamanit ... And to guess which of these stages, and especially in which setting, a jamb, with such a minimum of facts, is unrealistic, is impossible. - Akina
  • @Mike, embed in session? What is it like? - Bipa

2 answers 2

Try to specify the character set that is used when accessing the database. This is done using mysqli :: set_charset

To know what exactly you need to write - you need to know how you connect to the database, because there are obsolete functions mysql_ *, now instead of them you can use mysqli both in the procedural style and in the objective.

  • The initial encoding is latin1. I learned this with the help of '$ connection-> character_set_name ()'. Then I tried to change to utf8: if (!$connection->set_charset("utf8")) { printf("Ошибка ΠΏΡ€ΠΈ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ΅ Π½Π°Π±ΠΎΡ€Π° символов utf8: %s\n", $connection->error); exit(); } else { printf("Π’Π΅ΠΊΡƒΡ‰ΠΈΠΉ Π½Π°Π±ΠΎΡ€ символов: %s\n", $connection->character_set_name()); } if (!$connection->set_charset("utf8")) { printf("Ошибка ΠΏΡ€ΠΈ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ΅ Π½Π°Π±ΠΎΡ€Π° символов utf8: %s\n", $connection->error); exit(); } else { printf("Π’Π΅ΠΊΡƒΡ‰ΠΈΠΉ Π½Π°Π±ΠΎΡ€ символов: %s\n", $connection->character_set_name()); } if (!$connection->set_charset("utf8")) { printf("Ошибка ΠΏΡ€ΠΈ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ΅ Π½Π°Π±ΠΎΡ€Π° символов utf8: %s\n", $connection->error); exit(); } else { printf("Π’Π΅ΠΊΡƒΡ‰ΠΈΠΉ Π½Π°Π±ΠΎΡ€ символов: %s\n", $connection->character_set_name()); } , but as a result of this, the quackers were also displayed on the page - Bipa
  • The latin encoding doesn't support Cyrillic in principle. You should have everything in the same encoding - base, page. And then the task of a character set will help. And maybe it will not be necessary at all. - Vladimir Novopashin

Simply add header ('Content-type: text/html; charset=utf-8'); to the top of the page header ('Content-type: text/html; charset=utf-8'); :)

  • already decided, but thanks) And so, by the way, can you know how to prevent sql injections? - Bipa
  • It depends on what you are doing, whether you have a search on a database, adding records or queries which can - Daniel