views:

82

answers:

1

Hi, guys!

I'm trying to make an online dictionary for my own purposes (I know there are some other dictionaries, but they don't have what I need) and I have a file with words in the following format:

戚谊
戚誼
    [m1][b]qīyì[/b][/m]
    [m2]some translation[/m]
三州府
    [m1][b]sānzhōufǔ[/b][/m]
    [m2]translation #2[/m]

First two lines are the same character, but traditional chinese character and simplified, the third line is transcription, the forth line is the meaning of the character (translation). How can I store this data in proper columns of mysql database? (columns: simplified_character, trad_character, translation, transcription, etc)

Thank you!

A: 

There are three possible questions you are asking here:

  1. How to write to a MySQL database from PHP.
  2. How to read in a file from PHP and then write it to MySQL.
  3. What format to store data in MySQL.

I'm going to assume (3) but please do clarify if you intended something else. Basically, you will need to store characters in the UTF-8 format in the MySQL database to ensure that they are preserved.

You can do this by running the following query before anything else:

mysql_query("SET NAMES utf8")

All following queries should be interpreted as UTF-8.

sohum