This question has already been answered:

I make a small project that uses messages from the database. The scripts themselves (in php) and the output pages from the database in utf-8 encoding. The database is also created in utf-8 encoding.

If I write in the code when adding and when displaying the following:

mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER SET 'utf8'"); mysql_query("SET SESSION collation_connection = 'utf8_general_ci'"); 

then everything is recorded and displayed correctly in the database (the Cyrillic alphabet is displayed correctly), except ... some emoticons (which are critical for the "customer", as it turned out). Tell me how to be?

Reported as a duplicate by Visman members, Community Spirit 6 Sep '17 at 12:46 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

besides some emoticons

This is the problem of limiting the utf8 encoding in mysql. To bypass it, you must use utfmb4 encoding. To do this, it must be set for the table and for the connection.

Accordingly, create tables with utfmb4 encoding instead of "utf-8" (which is actually utf8), and after connecting write one line

 mysql_set_charset('utfmb4'); 

And yes, mysql_ * functions no longer exist. So in your small project you have to use PDO.

  • Duplicate answers: p - Visman