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:

$connection = mysqli_connect("localhost", "username", "password","db");

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

Leave a Reply

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