I have been trying to find a solution for past few hours but unable to do so. I have tried each and every possible solution on the Internet and this forum but nothing seems to be working. Here is the problem .
I want to store arabic data that user will type or paste in the textarea of form in mysql database. The website is arabic and form only contains this one textarea.
Important Points:
The website is displaying static arabic content correctly. utf8 charset is used throughout the website. So it is not a problem.
The table (home ) and the content field(content) are both set to utf8_unicode_ci collation so it is not a problem either.
Form is set to accept-charset='utf-8' so that's not a problem either.
When I insert arabic text using phpMyAdmin in the table I don't have any problem at all with it.
In fact when arabic text (entered through phpMyAdmin) in the table is retrieved on the website it shows perfectly.
But as soon as arabic data is entered in text area and sent to DB to be stored using insert query data transforms into ????
I am using
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');
After Connection so it is not a problem at all. As I said earlier the data is retrieved all right. I have uploaded the two images. Demonstrating my problem.
I am really stuck here and as you can see I have taken all the steps possible to solve this as well but this behavior is really weird. Please help.
The code I am using to insert the data into db is:
$content=$_POST["content"];
echo $content;
$sql="update home set content='$content'";
$result=mysql_query($sql) or die(mysql_error());
You can see the second echo statement. I added it to debug the problem. Data is shown perfectly in this echo. The problem rises in the query I suppose.
<form accept-charset="utf-8" ....>
– Akhilesh B Chandran Jul 29 '12 at 5:27