Hi Folks,
This might be a simple task for some people, but it is a very difficult one for me. I am having trouble with my work whenever I try to load data into a table in MYSQL. Whether I am using PHP and MYSQL, or JAVA and MYSQL or XML and MYSQL I always have this same problem. I have never been able to do it successfully once. I have read many tutorials so far and still have not been able to get it right. So I need your help please.
I am working with a tutorial I got from the MYSQL site now and it is not doing the correct thing for me. Maybe you have another idea for me.
1) The code below is my xml file, which I saved as person.xml in the httpdoc folder on the server (even with the file on my desktop, the same problem occurs). I am trying to import the data into mysql.
2) This is the code I used to create the MYSQL table.Code:<?xml version="1.0"?> <list> <person person_id="1" fname="Pekka" lname="Nousiainen"/> <person person_id="2" fname="Jonas" lname="Oreland"/> <person person_id="3"><fname>Mikael</fname><lname>Ronstrom</lname></person> <person person_id="4"><fname>Lars</fname><lname>Thalmann</lname></person> <person><field name="person_id">5</field><field name ="fname">Tomas</field><field name="lname">Ulin</field></person> <person><field name="person_id">6</field><field name ="fname">Martin</field><field name="lname">Skold</field></person> </list>
3) When I use the Import function in MYSQL to import the data, I get the error messages below. Nothing is imported into my table.Code:CREATE TABLE person ( person_id INT NOT NULL PRIMARY KEY, fname VARCHAR(40) NULL, lname VARCHAR(40) NULL, created TIMESTAMP );
Code:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?xml version="1.0"?> <list> <person person_id="1" fname="Pekka" lname="' at line 1Please, what am I doing wrong and could you have a look and tell me the best way to do it please?Code:<?xml version="1.0"?> <list> <person person_id="1" fname="Pekka" lname="Nousiainen"/> <person person_id="2" fname="Jonas" lname="Oreland"/> <person person_id="3"><fname>Mikael</fname><lname>Ronstrom</lname></person> <person person_id="4"><fname>Lars</fname><lname>Thalmann</lname></person> <person><field name="person_id">5</field><field name ="fname">Tomas</field><field name="lname">Ulin</field></person> <person><field name="person_id">6</field><field name ="fname">Martin</field><field name="lname">Skold</field></person> </list>
I have a huge excel data that I need to import into my PHP and MYSQL work. I cannot enter it all manually, I would like to import it, so your help will be great please.
Thanks,
Menre




Reply With Quote