Jump to content

Archived

This topic is now archived and is closed to further replies.

Mr Chris

Tab delimited issue - please help!

Recommended Posts

Hi Guys,

Trying to load a tab-delimited file to a MySql database, but getting the error message:

[b] INSERT INTO test (first_name, last_name, department, dob) VALUES ('')Column count doesn't match value count at row 1[/b]

But I have the same amount of columns in my table as I do in my tab-delimited file being uploaded. I've also echoed out the query, but still don't understand. Can anyone please advise by looking at the code below – especially my INSERT into statement?

Many Thanks

Chris

oh and here's the code

(Edit - won't let me post the code for some reason so a link can be found) [a href=\"http://www.thisisslough.com/code.txt\" target=\"_blank\"]HERE[/a]

Share this post


Link to post
Share on other sites
certailny tour query is wrong at this point --> INSERT INTO test (first_name, last_name, department, dob) VALUES ('')

The query should have the values entered or left blank atleast.
The right query would be

INSERT INTO test (first_name, last_name, department, dob) VALUES ('','','','');

Just note that when you explicitly mention the parameters of the insert statement, then you should mention the corresponding values also.

Please refer to th mysql manual & have a look at the insert SYNTAX.

Share this post


Link to post
Share on other sites
Are you parsing your input records into individual fields? If not, you should be. Take a look at the [a href=\"http://www.php.net/fgetcsv\" target=\"_blank\"]fgetcsv()[/a] function. It may help you.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.