Log in

View Full Version : Mysql Database Multi language Problem



round
01-03-2013, 10:17 AM
Hi,
My problem is I have set Collation=utf8_bin for Title field.
I am using Hindi Language. So when I insert from frontend, the output goes in backend properly like if we insert an English language word, it will be stored in as English, if I insert Hindi language word, it will be stored in as Hindi. Things are working perfectly in my Local but when I do the same in Live....., it is not working. I set the Title field Collation=utf8_bin.
But now when I insert another language word from frontend then whole table's Title field is getting changed to combination of some numeric & string values & it is not working properly.
So what should I do for it?

My Local Mysql Server Version is - 5.1.41
My Live Mysql Server Version is - 5.5.23

Any Idea?

Thanks
Kaushal

traq
01-03-2013, 08:38 PM
I have set Collation=utf8_bin for Title field.
"bin" means "binary." For text, you'll generally want a textual collation. For utf-8, the default is "utf8_general_ci", and that's a good choice.

note, however, that collation has to do with how MySQL sorts your records, not how it stores them.
You need to make sure your database is using UTF-8 encoding (e.g., by using CHARSET=UTF8 in your table definition).


I am using Hindi Language. So when I insert from frontend, the output goes in backend properly like if we insert an English language word, it will be stored in as English, if I insert Hindi language word, it will be stored in as Hindi.
This is an oversimplification.

I'm sure there's more than one encoding that can handle Hindi letters. There are many, many charsets that handle the basic latin alphabet (which is why there are very rarely problems with English letters).

In your case, you need to check not only the database encoding, but also the encoding for your database connection, your HTML page (both the <meta> tag and the HTTP header), and for your PHP script itself. They all need to use the same charset (UTF-8 is [almost always] the best choice).