Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Mysql database to support Arabic Language?

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?

like image 723
IamIronMAN Avatar asked Nov 19 '10 21:11

IamIronMAN


1 Answers

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" ...>
like image 156
user906220 Avatar answered Sep 22 '22 18:09

user906220