i have an mysql table member.
member name has arabic names. mname collation set as utf8_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);