Forum Moderators: coopster & phranque

Message Too Old, No Replies

MySQL INSERT Errors - please help :(

I'm so bad at this stuff

         

Chico_Loco

7:24 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In PHP My Admin when I go to insert the following code (from file), it gives me a syntax error on line on, but if I do it line by line it doesn't complain, it is windows line error being uploaded to a unix server:

insert into ringtones values ('1234','O','Justing Keen',NULL,NULL,'1','0','0','0','Car','logo9')
insert into ringtones values ('1540','O','Carlsberg',NULL,NULL,'1','0','0','0','Technology','logo5')
insert into ringtones values ('1541','O','Budweiser',NULL,NULL,'1','0','0','0','Technology','logo5')
insert into ringtones values ('1542','O','Coca Cola',NULL,NULL,'1','0','0','0','Technology','logo5')

andreasfriedrich

7:28 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try adding a ; at the end of each line.

Chico_Loco

7:45 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well Andreas .. the good news is that worked ..

The bad news is, the guy who generated the database made about 5,000 commands, all without the ending ";" -- Can you believe that?

andreasfriedrich

7:48 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well that it funny ;)

But it should be fairly easy to append a ; at the end of each line using an editor or a quick script.

Chico_Loco

7:59 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep - did that and now guess what ... there are muliple entries with the ID's for example
-----------------
insert into ringtones values ('2148','R','The Last Goodbye','Atomic Kitten','18/11/2002','1','1','1','1','Pop','ring8');
insert into ringtones values ('2149','R','That Feeling','DJ Chus pres Groove Foundation','18/11/2002','1','1','1','1','Pop','ring8');
insert into ringtones values ('2149','R','That Feeling','DJ Chus pres Groove Foundation','18/11/2002','1','1','1','1','Dance','ring15');
insert into ringtones values ('2150','R','Naughty Girl','Holly Valance','18/11/2002','1','1','1','1','Pop','ring8');
-----------------

As you can see there are 2 "2149" entries. When uploading the file, the MYSQL system chokes and gives me an error... is there anyway for it to silently continue / overwrite the entry and continue with the rest of the entries?

andreasfriedrich

8:19 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make the SQL statements read
[url=http://www.mysql.com/doc/en/INSERT.html]INSERT IGNORE[/url] INTO ringtones
. The record will not be inserted. It will be ignored silently.

Andreas

Chico_Loco

8:58 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Man you're good!

Worked perfectly .. Thanks

andreasfriedrich

9:10 am on Jan 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You´re welcome Chico_Loco :)