I am trying to save Arabic language in mysql database but it doesnot save in Arabic format. It shows question marks instead of Arabic. How to make it store values in Arabic.
I tried many queries seeing from internet but it doesnot changes. How to change it for Arabic. "ar_SA: Arabic - Saudi Arabia" Please suggest a way?
i use WAMP Server. (windows,apache,mysql,php).
//so important
FIRST :
in phpmyadmin or MySQL : make sure that Mysql Database is utf. make sure that the your database and it's tables are utf-general-ci
after connecting to Mysql immidiately (before choosing your DB) make this order.
mysql_set_charset('utf8');
example :
<?php
//connect to MySQL
mysql_connect("localhost", "user", "password") or die(mysql_error());
mysql_set_charset('utf8'); // that's the order.
echo "Connected to MySQL<br />";
//connect to your DB
mysql_select_db("mydb") or die(mysql_error());
echo "Connected to Database";
?>
SECOND : in the meta data in the php file make the meta data as following :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Third : Make sure that the php file it self is utf-8 enabled . u can make sure in your IDE settings , or if u work on notepad++ or Komodo Edit then u can find it in the status bar at the bottom of the window , right side.
// i tried this but it didn't have effect.
in the header of the php file (before every thing).
<?php header("Content-type: text/html; charset=utf-8"); ?>
in the form submitted:
<form accept-charset="utf-8" ...>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With