Inserting Arabic text with PHP into MySQL Database

We need to set the encoding of texts we store into database to UTF-8 if we work with Arabic texts. Otherwise, Arabic texts appear like ?????????? in our database.

Once we create a database connection variable, we must set it’s charset into UTF-8 like this:

And one more thing, we need to set our table (or a specific row) collation to utf8_general_ci like this:

Do you like this post? Consider a donation 😀

Published by


Habibie is an Indonesian freelance frontend-backend web programmer and cross platform mobile app developer. He's also good at graphics design, video editing, visual effects and animation.

Leave a Reply

Your email address will not be published. Required fields are marked *