Hello,

I have looked everywhere on the web for a solution to this problem.

I am trying to store arabic characters into mysql via an html form.

i have set the meta charset to utf-8 and have tried mysql_query('set names 'utf=8'")

but still i get garbled characters in my table:

لربيلبي

Please advise!

thanks faith but that didnt help with my problem.

:/

did you try ansi_unicode_?

i have something like this
i insert data into db
in the db the data is not readable
but when select it on a php page
everything goes well
so the application is running anyway

is it local or remote located database?
if locale chech my.ini, find default charset and change it to ansi_unicode
collation in the same way.

Got it working!

mysql_query("set names 'utf8'");

Thanks everyone for your replies..

To 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:

mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');

for more details:
http://www.adviesenzo.nl/examples/php_mysql_charset_fix/

I have tested it and it works well, I hope that would be helpful..

thanks!

hey i was have this problem for two days and i have found the solution .. you have to add this code
accept-charset="utf-8"
to your forum

HOW TO PROPERLY DISPLAY THE ARABIC LETTERS USING A HTML/PHP PAGE AND MySQL :

STEP #1:

Choosing the right character set for the MySQL database in Wampserver®:

  1. Create a new table.
  2. Select "utf8_bin" as character set.
  3. Save.

STEP #2:

  1. Open the "results page" (page which will be used for the request) and find the following line in the "Code area":

    mysql_select_db($database_MyDatabase, $MyTable);

  2. Copy/paste the two following lines immediately below the line:

    mysql_query("SET NAMES cp1256");
    mysql_query("set characer set cp1256");

The result will be:

mysql_select_db($database_MyDatabase, $MyTable);
mysql_query("SET NAMES cp1256");
mysql_query("set characer set cp1256");
  1. Give to the "Results page" de following character set "Windows-1256" just like that :

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />

  2. Save.

Source of this Tutorial found on sumarabus (many Tutorials on the Arabic language and the creation of web pages) - direct line to the Tutorial (with screen shot) at the end of the response.

Ma3a assalama,
Mister Arabic.

Link:
www.sumarabus.com/2_Dynamic/6_Computer_Tutorials/Tutorials/Wampserver/Wampserver_2.php

Edited 2 Years Ago by pritaeas: Added markdown. Removed self-promotion links. Be careful not to post too many self-promotion links.

This article has been dead for over six months. Start a new discussion instead.