阿拉伯语语言转换php到mysql [重复]

This question already has an answer here:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
mysql_query("update `mudasser`
             set `name`='$name',
                `ar_name`='$ar_name',
                `address`='$address',
                `type`='$type',
                `telephone`='$telephone',
                `date_added`='$date',
                `image`='$file'
            where `id`='$id'"

when i echo the query this is the result

update `mudasser` set `name`='Boknan', `ar_name`='بوكنان', `address`='E2', `type`='Abaya Galabia', `telephone`='2535338', `date_added`='2015-06-01 08:54:11', `image`='Boknan.jpg' where `id`='128'

You can see the arabic name appearing correct but in the database the arabic name is somehow like this ???????

If i run this query directly in mysql, it runs perfect and it is also reading correct arabic in php page.

For reference i am using <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> in php and also using utf-8 in db.

I have searched the net and Stackoverflow but i cant find any answer.

</div>

Try this before executing the update query.

either

mysql_query("SET NAMES utf8");

or

mysql_query("SET NAMES utf8mb4");

utf8mb4 is preferred. Which was introduced in MySQL 5.3.3, use it if possible.

read more about difference in UTF8 and UTF8mb4 and how to switch to mb4

Please check your table's CHARSET and COLLATE Properties.

For columns check "Encoding" and "Collation" properties.

CHARSET/Encoding should be utf8 Collate/Collation should be utf8_bin

  1. ar_name need to be a nvarchar type
  2. Put N in front of the arabic characters - N'بوكنان'