1
<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.

Federkun
  • 36,084
  • 8
  • 78
  • 90
Sameed
  • 105
  • 1
  • 11
  • Uhhhmmm @leggendario I think you edited out an important part of the question... (the question marks) – PeeHaa Jun 01 '15 at 13:05
  • Your current character encoding is probably set incorrectly. – Seiyria Jun 01 '15 at 13:05
  • @sameed when you say "somehow like this" were those question marks meant to be there? As in, that is what you see? – PeeHaa Jun 01 '15 at 13:06
  • the code is working perfect otherwise, the problem is just with arabic. if i write this query in mysql it runs perfectly fine. but through PHP its not entering the correct arabic value – Sameed Jun 01 '15 at 13:09
  • yes those were the question marks that meant to b there, part of question – Sameed Jun 01 '15 at 13:09
  • @Leggendario no worries. It was easy to miss :) – PeeHaa Jun 01 '15 at 13:11

3 Answers3

1

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

MrSimpleMind
  • 7,890
  • 3
  • 40
  • 45
0

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

Rishav Rastogi
  • 15,484
  • 3
  • 42
  • 47
0
  1. ar_name need to be a nvarchar type
  2. Put N in front of the arabic characters - N'بوكنان'
Liu
  • 970
  • 7
  • 19