Hi,

I'm trying to store data in languages other than English (mainly RTL languages) in MySql, the first time I've stored the data I found that it was saved like this:

??? ?????? ????? ?????? ?????? ???? ??????? ???? ?? ??????? ?? ??? ????? ????? ??? ??? ?? ??? ???? ????? ??? ??? ???? ????? ???? ????.

So I did some search, and found that a solution suggested by a guy who faced the same problem. The solution was to add this line:

mysql_query("SET NAMES 'UTF8'");

I added it and it did not show anything even the ?????, but if I tried to insert text in English, it shows in the records the text inserted and also on the web page. I've set the collation to be utf8_unicode_ci and utf8_bin, but it didn't do anything.

Is there anything I should do in HTML code, in php code, in mysql settings to make work?

Any suggestions, ideas, a better way to make work is highly appreciated.

    You need to be utterly consistent about your encodings. Mixing and matching will result in chaos.

    Use only MySQL 4.1 or higher- lower versions don't support encodings correctly. For preference, use MySQL 5.

    Assuming your pages are in UTF8, your tables are in utf8 and your connection is in utf8 (SET NAMES utf8 will do this), it should all work.

    Collation utf8_general_ci is probably the one you want- but there are plenty more to choose from (Use "show collation like 'utf8%';" in the mysql prompt to see them all)

    Assuming everything is in utf8, it should work. If it isn't, it won't.

    You need to ensure that all input / output both via the web and other methods (e.g. email) are aware of the right encoding and test with common applications to ensure that they pick it up correctly.

    Mark

      Thanks MarkR for the input.

      I'm using MySQL 5, PHP 5.

      I'm using utf8_unicode_ci for the collation.

      I've removed this line from the code:

      mysql_query("SET NAMES 'UTF8'");

      After doing so, I was able to insert data in other languages, but if I try to browse the DB using phpmyadmin I get unreadable symbols.

      When I show the results on a web page using IE or FF it shows the desired results.

      Any explanation for this??😕

        bprof wrote:

        Thanks MarkR for the input.

        After doing so, I was able to insert data in other languages, but if I try to browse the DB using phpmyadmin I get unreadable symbols.

        When I show the results on a web page using IE or FF it shows the desired results.

        Any explanation for this??😕

        First guess, phpmyadmin isn't aware of / capable of setting encodings?

          do u have the other languages installed on your machine?

          e.g. if i goto babel fish and translate to Chinese or Japanese and dont have the languages installed on windows all ill get is a bunch of nonsensical characters

          check that

            Thanks Sxooter,

            I were able to save data using phpmyadmin directly and it was saved correctly and retrieved correctly too. And when I browse the data using phpmyadmin it shows the data correctly. The problem only occurs when I save the data using a form on a page.

            Thanks scrupul0us,

            I have all the languages needed installed on my machine.

              Write a Reply...