Mysql Collation issue for multi language concept - php

For multi language, i have tried mysql collation with "utf8_unicode_ci" and also "utf8mb4_unicode_ci", but i getting issues.
1) when i update the text by coding. the output in phpmyadmin showing "எமà¯à®à®ªà®¿" junk character, but the output in website is displaying correctly.
2) when i update the text by directly in phpmyadmin. the output in phpmyadmin showing correct, but the output in website is showing "??????" characters.
How to showing correct in both phpmyadmin and website?
Note: the language text is tamil text

You need to use utf8_general_ci encoding for multi-language is widely used.
Also, when you need to do operation from code set character encoding to utf8 from mysql.
Hope fully it will solve your issue.

Related

PHP 5.6 encoding latin1 MySQL encoding

After migration from PHP 5.3 to PHP 5.6 I have encoding problem. My MySQL database is latin1 and my PHP files are in windows-1251. Now everything is displayed like "ñëåäíèòå àäðåñè" or "�����".
It should be display something in Cyrillic like "кирилица". I've tried mysqli_set_charset but it didn't solve my problem.
First, let's see what you have in the table. Do SELECT col, HEX(col)... to see how these are encoded. Here is the HEX that should be there if it is correctly utf8-encoded:
ñëå --> C3B1C3ABC3A5; кир --> D0BAD0B8D180
If you don't get those, then the problem was on inserting, and we may (or may not) be able to repair the data. If you have C390C2BAC390C2B8C391E282AC for the Cyrillic, then you have "double encoding", and it will take some work to 'fix'.
utf8 needs to be established in about 4 places.
The column(s) in the database -- Use SHOW CREATE TABLE to verify that they are explicitly set to utf8, or defaulted from the table definition. (It is not enough to change the database default.)
The connection between the client and the server. See SET NAMES utf8.
The bytes you have. (This is probably the case.)
If you are displaying the text in a web page, check the <meta> tag.
Halfer is right. Change both your PHP and MySQL encoding, first the PHP with
mb_internal_encoding ("UTF-8");
mb_http_output("UTF-8");
to UTF-8, at the top of your PHP pages.
If you miss out the "UTF-8" and print the output from these finctions, it will show you your current PHP encoding - probably windows-1251
Also note that with MySQL you need to change the character encoding on the row in the table as well as on the table itself overall and on the database itself overall, as the defaults will remain latin1 so any new fields you add would be latin1 without being carefully checked.
If you are trying to save Cryllic text to the database you will need the correct Cryllic character set in the database, rather than latin1

mysql shows chinese characters like squares

I want to save chinese characters in mysql db, charset is set to UTF8 via connecting to db, also the field's charset is utf8, and collation - utf8_general_ci,
But instead of the word it shows squares. I use sqlyog.
There is one thing, if I make request and echo the word in the browser if shows the right chinese word.
So, I am wondering why it shows the correct word in browser, when in db it is like squares and vice versa.
I am afraid that maybe via exporting or importing in the future I can have some data lose.
Thanks
Your data might be stored correctly in the DB, but read wrongly by sqlyog.
I haven't used sqlyog, but this problem might be because of the way sqlyog connects to MySQL - look for parameters in sqlyog connection to DB that are related to character set and make sure they are also utf8
I had a similar problem when I had to insert Latin characters to the database, I used mb_convert_encoding($str, 'utf8', 'HTML-ENTITIES') and it got stored correctly in the database and wen I had to show it in the html page I just had the encoding=utf-8

Arabic Fonts Show As Question Marks After Editing Online

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
Have you tried using mysql_set_charset
mysql_set_charset("utf8");
seems you are doing everything right. but did you make all this before inserting data?. try cleaning up database and inserting from the scratch
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.

Website/Database text encoding issue

We imported a website from another server to our server. The code and database is 100% the same.
But the text on the website seems to have a wrong encoding.
Example:
In the database the word "Australië" is "AustraliĂŤ" while on the website its shown as Australi??.
I can fix the ?? with adding mysql_set_charset("utf8",$this->db); after the database connection.
But then its shown like in the database like "AustraliĂŤ" wich is incorrect. I tried different encodings in apache, after database and in meta tags.
The easiest way would be to change the data in the database but there is to much data in it to do this.
Anyone has a solution for this problem? Have been searching and trying a lot off things for hours.
You could try to:
set the MySQL connection collation to uft8_general_ci in the database
run SET NAMES 'utf8' and SET COLLATION_CONNECTION=utf8_unicode_ci in your PHP files
make sure all your PHP files are saved with UTF-8 encoding and do not feature a BOM
make sure the cells in your table are utf8_general_ci
make sure that MySQL charset is UTF-8 Unicode (utf8)
This is what I have. With this setup I see all characters in the database (phpMyAdmin) as they really appear on the website itself.
I have encountered a similar issue when I had a mismatch of encodings, i.e. I was saving data to a UTF-8 database by a ISO-8859-1 encoded site...
Hope this helps you.

Is it possible to show data of different encodings in the same page?

I have two tables here - one is in UTF and holds Arabic text as it can be read. The other one has a different encoding however and the content is Arabic however in the database its displayed as
ÈöÓúãö Çááøåö ÇáÑøóÍúãóäö ÇáÑøóÍöíãö
I have to show data from both tables on the same page - the page is UTF encoded however I'm not sure if this can be done or if its possible. What do i do? My database is mysql and I'm using php.
Is it possible to convert the encoding of the contents of the other table into UTF8 btw?
You have to use mb_convert_encoding() first, on everything, to make sure it's all in UTF-8 to begin with. http://us3.php.net/manual/en/function.mb-convert-encoding.php Then it should display, assuming your HTML's charset is UTF-8 and the users have the appropriate fonts installed.
Also, virtually all consoles and a great many free online SQL commanders (like PHPMyAdmin) are not UTF-8 aware and print out jibberish. I have not yet found a free SSH client that supports UTF-8; if it's a big deal, invest in SecureCRT.
EDIT:
Excuse me. I don't read Arabic at all, but I did get Arabic back. please tell me if this is the correct text, and if so, accept this answer ;_)
ب?س?ك? افف?م? افر??ح?ك?ل? افر??ح?ٍك?
The code I used to get this was:
header('Content-Type: text/html;charset=utf-8');
echo mb_convert_encoding('ÈöÓúãö Çááøåö ÇáÑøóÍúãóäö ÇáÑøóÍöíãö', 'utf-8', 'iso-8859-6');
I found the Arabic encoding via this page: http://a4esl.org/c/charset.html
Cheers!

Categories