How to make Mysql database to support Arabic Language?

会有一股神秘感。 提交于 2019-12-06 02:01:00

问题


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?


回答1:


Just use UTF-8 in the page's encoding, in the database connection, and the database itself.




回答2:


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" ...>



回答3:


Make sure your database encoding and collation is utf8_general_ci



来源:https://stackoverflow.com/questions/4229593/how-to-make-mysql-database-to-support-arabic-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!