'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;

Solution 1:[1]
See this answer: you need to have utf8mb4 set everywhere on the way when saving and loading, PHP must know to use the encoding as well when communicating with database.
After you added screenshot: there most probably already is bad data in your database - I would guess the problem is in the way you save the emoji to the database, not in the way you load it (could be both though).
Solution 2:[2]
I had the same problem. I was using the CodeIgniter framework.
so I changed the below code in application\config\database.php
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
and it started storimg emojis in database.
Solution 3:[3]
I was also facing same issue in Codeigniter-4 of emojis reading ???? in mysql database after successful installation of emoji-picker
Thanks @ankit singh I was able to resolve it.
First had changed the COLLATE utf8mb4_bin on the comments table but it still continued showing ????.
So change in App->Config->Database.php settings to below helped
'charset' => 'utf8mb4',
'DBCollat' => 'utf8mb4_bin',
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LuH |
| Solution 2 | iknow |
| Solution 3 | lwegaba |
