The bytes in the message give it away: \xD8\xA7\xD9\x84 is the Arabic «ال» in UTF-8, so the column won’t accept Arabic. Bytes starting with \xF0\x9F are an emoji, which the old utf8 charset has no room for. With strict mode on, MySQL refuses the write with this error; with it off, it silently saves ? in place of each character, which is why Arabic text turns into ????.
What you’re seeing
| Symptom | Meaning |
|---|---|
| Error 1366 | Strict mode refused characters the column can’t store |
???? |
Connection or column isn’t UTF-8; characters were replaced on save and are lost |
العربية |
UTF-8 text read or stored as latin1; usually repairable |
| Only emoji fail | The column is utf8 (3 bytes) and needs utf8mb4 |
Causes
- The database or table was created with the default
latin1charset on an old server or from an old dump. - The app’s connection doesn’t set a charset, as in old PHP code without
set_charset. - Using
utf8instead ofutf8mb4, so emoji fail. - Importing a file that isn’t UTF-8, or choosing the wrong charset on import.
How to fix it
-
Back up the database by exporting it before changing anything.
-
Check the current charset in phpMyAdmin’s SQL tab:
SHOW CREATE TABLE posts;
SHOW VARIABLES LIKE 'character_set%';
- Convert the database and tables to utf8mb4:
ALTER DATABASE cpuser_shop CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE posts CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Or in phpMyAdmin: select the database, open Operations, choose utf8mb4_unicode_ci under Collation and tick Change all tables collations.
- If you see characters like
ال, UTF-8 data is sitting in a latin1 column.CONVERT TOwould garble it further; go through a binary type instead:
ALTER TABLE posts MODIFY title VARBINARY(255);
ALTER TABLE posts MODIFY title VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- Set the connection charset in your app:
// PDO
$pdo = new PDO('mysql:host=localhost;dbname=cpuser_shop;charset=utf8mb4', $user, $pass);
// mysqli
$db->set_charset('utf8mb4');
In Laravel, config/database.php should have 'charset' => 'utf8mb4' and 'collation' => 'utf8mb4_unicode_ci'. In WordPress, in wp-config.php:
define( 'DB_CHARSET', 'utf8mb4' );
-
When importing, pick
utf-8under Character set of the file on the Import page. -
In your pages, add
<meta charset="utf-8">and save files as UTF-8.
Text already saved as ???? won’t come back by converting; re-enter it or re-import it from the original source once the charset is fixed.
Prevention
- Create every new database and table with
utf8mb4_unicode_cifrom the start. - Always set the charset on the connection rather than relying on the server default.
- If you hit
1071 Specified key was too longafter converting on an older version, shorten indexed columns, for example withSchema::defaultStringLength(191)in Laravel.
On ArabyHost
Databases on ArabyHost run on MariaDB/MySQL with phpMyAdmin, so you can check and convert everything from your browser. Choose utf8mb4_unicode_ci when creating tables for Arabic content, as in the MySQL database guide. The charset itself is explained in utf8mb4 and Arabic text, and WordPress setup in WordPress for Arabic and RTL. If you can’t tell which table or connection is at fault, the Araby AI assistant reads your error log and explains the fix.
FAQ
What's the difference between utf8 and utf8mb4?
MySQL's utf8 stores up to 3 bytes per character: enough for Arabic, but it rejects emoji and some newer symbols. utf8mb4 stores up to 4 bytes and is the right choice for any Arabic site today.
Can I recover text that turned into question marks?
If it was stored as ???? the original characters are gone and can't be converted back. If it shows as strange characters like ال, the data is usually still there and can be repaired after taking a backup.
Which collation should I use for Arabic?
utf8mb4_unicode_ci is a safe, widely used choice. MySQL 8 also has utf8mb4_0900_ai_ci, but some MariaDB versions don't know it and fail with Unknown collation on import, so avoid it if the database may move.