Search code examples
phphtmlmysqldatabasephpmyadmin

Storing emojis in MySql database. Showing ??? in phpmyadmin


Showing question mark ??? while storing emoji in a MySQL database. I have already set database and table collation to utf8mb4. But still, it's showing ??? ??? instead of emoji in the database. I also tried to change existing row in PHPMYADMIN console. But nothing is working. Showing ??? instead of Unicode characters. I have also changed Storage Engine for the table. InnoDB, MyISAM

SET NAMES utf8mb4;

ALTER DATABASE your_database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

table structure and all elements


Solution

  • I finally got the solution. We will have to set our connection charset to utf8. After declaring connection variable set charset:

    mysqli_set_charset($con,"utf8");
    

    After that your emoji or any other unicode text will be encrypted and saved in mysql database.