1
votes

I created an Arabic website using PHP 5.3, MySQL 5 and PHPMyAdmin 3.4.

On every page, I use the "utf-8" character set. I include the following line on every page:

http://jsfiddle.net/Hh7mk/

The website works fine offline (on local server (localhost)). Even after I edited and inserted new Arabic writings into the database.

The problem is when the website is online. All Arabic fonts are displayed properly, but after I edited or inserted new Arabic writings into the database online, the new writings are displayed as question marks.

My settings (online):

  • PHPMyAdmin MySQL Connection Collation : utf8_general_ci.

  • PHPMyAdmin MySQL charset : UTF-8 Unicode (utf8).

  • The database and tables collation : utf8_general_ci.

In the connection file, I have included mysqli query SET NAMES 'utf8' and SET CHARACTER SET utf8.

I also have tried to change the collation to "cp1256_general_ci", and the pages character set to "windows-1256", but the fonts still show as question marks.

Why the Arabic fonts show as question marks after I inserted/ edited them online? How to fix this?

Thank you in advance

3
How are you editing it online?Ansari
I use a form to post the data into the database, with TinyMCE as the editor. Before updating the data, I establish a connection with a file that has mysqli query SET NAMES 'utf8' and SET CHARACTER SET utf8 in itBayu
Try isolating the origin of the error. Do you have some kind of access to the database via shell or phpmyadmin? Can you log the update query sent by your form? Can you try using a simple textbox instead of TinyMCE?Ansari
Yes, I can access the database using PHPMyAdmin. I tried to use Javascript alert to find out what the update query sent, and it displayed the correct Arabic fonts. So I think the problem must be not the update query or the TinyMCE editor, but the web server or the database. This is strange because I have used the right type of collations for the database and the tables. Do you have any other idea?Bayu
Log the queries to a plain text file if possible. Check the row in phpmyadmin before and after your query and see what the difference is.Ansari

3 Answers

3
votes

Have you tried using mysql_set_charset

mysql_set_charset("utf8"); 
0
votes

seems you are doing everything right. but did you make all this before inserting data?. try cleaning up database and inserting from the scratch

0
votes

The ASCII ? mark's code is 63 which is the first byte of all Arabic characters (each character has two bytes). Having your strings turned to ? means that only the first bytes of your characters are stored/retrieved. This is an indication that somewhere is your store/retrieve process you've got a bottleneck in which only ASCII characters can pass. My bet is on MySQL. The best way you can find this out is to use your local server's code (a local PhpMyAdmin shall do) connecting to your production server's MySQL. If the problem remains it shows that it's MySQL's configuration doing (considering the fact that your local PhpMyAdmin works fine with your local MySQL). I can only give you ideas on how to investigate the problem. You need to find the problem itself on your own.