Click to See Complete Forum and Search --> : Inserting Chinese Characters into DB


Jamina1
06-12-2008, 09:42 AM
Hello!

Our company has recently expanded our operations into China, and thus we're starting to get vendors whose contact information is only available in chinese. We have a database that contains information on all our vendors, and a website in PHP that pulls it out and displays it nicely.

Our problem currently is this -

With standard MySQL queries such as INSERT INTO table ('some chinese characters here') the resulting data, when viewed through PHPMyAdmin is garbled. If edited after the fact using PHPMyAdmin, the chinese characters are entered and show up properly. This table also needs to be able to store data in English simultaneously, sometimes in the same rows.

I've added the mysql_query("SET NAMES 'utf-8'"); and mysql_query("SET CHARACTER SET 'utf-8'"); at the beginning of our queries, but it hasn't helped at all. Also, the rows are all set to collation 'utf_unicode'

I'm at wits end, as I have about 100 records I need to enter and I don't want to have to do them by hand one at a time.

chazzy
06-13-2008, 02:48 PM
you wouldn't want to use UTF-8 in this case. You need a different encoding.

Jamina1
06-13-2008, 02:49 PM
you wouldn't want to use UTF-8 in this case. You need a different encoding.

Well then what should we use?
Up to this point, the database has contained only english characters, and those were all entered with the default Latin 1 encoding. We need the database to go both ways, how would you suggest we do that?

chazzy
06-13-2008, 02:59 PM
ah wait. the issue might be how your PHP system is configured. do you have the data from your php.ini? it's also not clear to me how they're entered in the first place. you wrote the script?

legendx
06-13-2008, 03:36 PM
I THINK utf-8 is correct but I know very little on the subject. Encoding is a very frustrating issue to deal with. I won't be able to help much but I have found that once in a blue moon this helps some people:

If you are using a windows machine, open your control panel and go to Regional and Language Options. Click the Languages tab and click the two checkboxes at the bottom. This will install a lot of the asian languages. Sometimes data is actually being stored and retrieved correctly, it's just that the users machine can not interpret them because they don't have the languages installed.
- If anyone can explain this better please do.. cause I'd be interested in knowing more.

Jamina1
06-13-2008, 03:49 PM
ah wait. the issue might be how your PHP system is configured. do you have the data from your php.ini? it's also not clear to me how they're entered in the first place. you wrote the script?

I'm using a class that reads Excel files and then I can use the data and insert it into my SQL database. However, I actually think this problem is Excel's fault.
Viewing it in excel, the characters appear fine. Attempts to export the data (to CSV or anything else) turns all the chinese characters into gibberish. That's probably why php is having a fun time with it.

I've configured my php.ini to work with utf-8, so I know it isn't PHP. (Plus, using PHPmyadmin the data goes in just FINE! Just that its like 100 records that I have to import, and doing it by hand isn't really an option...) And I set the mysql configuration using the SET NAMES 'utf-8' so it can't be sql either.
Thus, it must be the data source, right?