0

In my mysql database, I use utf8mb4_general_ci encoding.

In the CMS config, the UTF-8 header encoding is set ('Content-Type: text / html; charset = utf-8');

And also:

mysql_query ("set_client='utf8'");
mysql_query ("set character_set_results='utf8'");
mysql_query ("set collation_connection='utf8_general_ci'");
mysql_query ("SET NAMES utf8");

But if I send a request through PHP (If I use not Latin!), then in the database I get the following:

enter image description here

And vice versa, what is displayed normally in the database, passing through PHP breaks as a result.

What could be the problem?

owals owals
  • 113
  • 5
  • 3
    Something you should bear in mind - [Why shouldn't I use mysql_* functions in PHP?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Nigel Ren Oct 28 '19 at 08:48
  • **Warning:** `mysql_*` extension is deprecated as of PHP 5.5.0, and has been removed as of PHP 7.0.0. Instead, either the [mysqli](https://www.php.net/manual/en/book.mysqli.php) or [PDO_MySQL](https://www.php.net/manual/en/book.pdo.php) extension should be used. See also the [MySQL API Overview](https://www.php.net/manual/en/mysqlinfo.api.choosing.php) for further help while choosing a MySQL API. – Dharman Oct 28 '19 at 09:49
  • Does this answer your question? [Why shouldn't I use mysql\_\* functions in PHP?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Dharman Nov 27 '19 at 19:52

1 Answers1

0

Use

mysql_set_charset('utf8mb4')

instead of your first line.

https://www.php.net/manual/en/function.mysql-set-charset.php

olegsv
  • 1,422
  • 1
  • 14
  • 21