PDA

View Full Version : Error received when trying to upload SQL code with phpMyAdmin


chump2877
01-16-2005, 02:36 AM
Here's my situation:

I've got a .csv file that I created with Excel...I noticed that when I opened up this file in a text editor, that there were lots of trailing commas on subsequent lines following the actual data...I cleaned up the file by deleting these commas, and resaved the file as .csv in my text editor....Then, I used a conversion tool that I found (you can see it HERE (http://www.sqldbu.com/eng/sections/tips/mysqlimport.html)) to convert the .csv file to core SQL (i know the conversion tool works because I've used it before)...Now, I'm trying to upload the resulting text file with SQL code to my server using phpMyAdmin...I feel like I've done everything right so far, but I keep getting this error from phpMyAdmin when I try to upload the SQL code:

Error

SQL-query :

CREATE TABLE IF NOT EXISTS parts2(

AC0020 CHAR( 10 ) NOT NULL default '',
Microphone_Headset CHAR( 53 ) NOT NULL default '',
5.35CHAR( 42 ) NOT NULL default '',
RECNO INT( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
PRIMARY KEY ( RECNO )
)

MySQL said:


#1064 - You have an error in your SQL syntax near '5.35 CHAR(42) NOT NULL default '', RECNO INT(10) unsigned NOT NULL auto_incremen' at line 1

I believe the syntax should be correct and there should be no typos, but the error seems to indicate otherwise....I'm really at a loss here...I'd include the SQL code, but the file is too large to post here....I can email it to someone if they cared enough to take a look at it....

Thanks in advance for any help you can provide with this one!! :)

chump2877
01-16-2005, 05:21 AM
Bottom line, if anyone could point me towards a free SQL debugging utility, I would be very, very grateful !!!!!

:D

raf
01-16-2005, 07:10 PM
euh ...

5.35CHAR( 42 ) NOT NULL default '',

should be something else. in any case, you need a space between columname and columntype, so

5.35 CHAR( 42 ) NOT NULL default '',

but 5.35 is not realy a good variablename. and it should be enclosed in backticks --> `5.35`

so working code would be:

CREATE TABLE IF NOT EXISTS parts2(

AC0020 CHAR( 10 ) NOT NULL default '',
Microphone_Headset CHAR( 53 ) NOT NULL default '',
`5.35` CHAR( 42 ) NOT NULL default '',
RECNO INT( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
PRIMARY KEY ( RECNO )
)


using my psychic powers, i would say that the code you used to convert the csv into a dumpfile, expects a csv file where the first line contains the tableheader --> the columnnames, whereas your csv only contains the data...

chump2877
01-16-2005, 10:47 PM
Thanks, you were absolutely correct...I guess I don't know my SQL errors as well as I thought.... :thumbsup: