php - Arabic text not storing in the mysql data base?
i have an mysql table member.
member name has arabic names. mname collation set asutf8_general_ci
.
when user enters arabic name its stores in the db table as some other characters. but when i retrieve and display it in the site, it displays correctly as Arabic text. why its not storing as arabic text in the database table ?
i tried this but only i am getting question marks no Arabic text...
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');
Php Code:
using simple php.
$mname = $_POST['mname'];
$email = $_POST['email'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$city = $_POST['city'];
$country = $_POST['country'];
$query="insert into member (mname, email, password, gender, age, city, country) values ('$mname','$email','$password', '$gender', '$age','$city','$country')";
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');
mysql_query($query);
Answer
Solution:
that could be problem with that to set meta tag
also you have to set column collection type it should be same
utf8_general_ci.
more over table and database type will also consider as same.And also some point to be carefull like
o read ,write and sort 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:
for more details: LINK
let me know if i can help you more.