Mr Chris Posted April 20, 2006 Share Posted April 20, 2006 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 ThanksChrisoh 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] Quote Link to comment Share on other sites More sharing options...
slashemail Posted April 20, 2006 Share Posted April 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.