Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Question: How can I store Text written in Arabic into MySQL table?

Current situation: I always get this error

Warning: #1366 Incorrect string value: '\xD8\xAD\xD8\xB1\xD9\x81' for column 'arabic' at row 1

every time I try to input something in Arabic, I googled a bit and found that setting charset into utf8_bin is solution, so I tried that and yet still getting same error, and the data is stored as "?????"

Example

UPDATE `ci`.`patients` SET `Name` = 'حرف' WHERE `patients`.`ID` =3;

Result

??? is stored into DB

share|improve this question
1  
What exactly did you try to switch the charset to utf8? –  arkascha Dec 1 '12 at 8:29
 
@arkascha i tried to switch table collation into utf8_bin –  Momen M El Zalabany Dec 1 '12 at 8:50
 
And your client runs in which encoding? And the input is in which encoding? –  arkascha Dec 1 '12 at 8:55
add comment

2 Answers

Arabic text in mysql database using php correctly, make sure that:

1- MySQL charset:UTF-8 Unicode (utf8)

2- MySQL connection collation: utf8_general_ci

3- your database and table collations are set to: utf8_general_ci or utf8_unicode_ci

Then, add this code in your php script when you connect to db:

mysql_query("SET NAMES 'utf8'"); mysql_query('SET CHARACTER SET utf8');
share|improve this answer
 
how can i construct my tables that all fields can accept arabic ? –  Momen M El Zalabany Dec 1 '12 at 8:49
add comment

Set MySQL table charset to utf8, collation to utf8_general_ci or utf8_unicode_ci.

I'm not into php stuff but if you have some kind of connection string you should also set charset to utf8 within that string.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.