p_T_s Posted October 23, 2008 Share Posted October 23, 2008 When i try and add a new item or edit an item i get an error. The error below is from trying to edit an item... QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO items VALUES('12',7,'Bottle of Rum','Gains you brave but loses energy',100,10,1, '1', 'a:4:{s:4:\"stat\";s:5:\"brave\";s:3:\"dir\";s:3:\"pos\";s:8:\"inc_type\";s:6:\"figure\";s:10:\"inc_amount\";i:10;}', '1', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3:\"neg\";s:8:\"inc_type\";s:7:\"percent\";s:10:\"inc_amount\";i:50;}', '0', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3:\"pos\";s:8:\"inc_type\";s:6:\"figure\";s:10:\"inc_amount\";i:0;}', 0, 0) Can someting shed some light on what could cause this? Cheers. Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error Read the error message: It tells you *exactly* what the problem is: Column count doesn't match value count at row 1 So the number of columns you are inserting does not match the number of columns in the table. Check the table definition, and check the SQL that is attempting the insert. It is recommended that you never perform blind inserts like this: INSERT INTO `table` VALUES (1, 2, 3); You should instead ALWAYS specify the columns like so: INSERT INTO `table` (`field1`, `field2`, `field3`) VALUES (1, 2, 3); The reason being simple: If at some stage you modify the table definition, often by adding a column, you would normally have to go through all your code amending every query. With full inserts, you will reduce the impact of this issue dramatically. Quote Link to comment Share on other sites More sharing options...
radio_active Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error It means you probably didnt fill out every form when you went to create an item, if you create armour you have to put a 0 into the weapon damage and if you create a weapon you need to put a 0 into the defense. You have to fill out every form putting a 0 in the ones you do not need. Quote Link to comment Share on other sites More sharing options...
Tonka Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error radio_active are you serious, the error is "QUERY ERROR: Column count doesn't match value count at row 1" he added an extra column for something an that is causing the problems. also if you look at the queries you can see that there are 0's there for weapon/armor Quote Link to comment Share on other sites More sharing options...
Canjucks Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error Tonka, what happened was an item was being edited, was working fine and have not been aware of any new columns being created. Edited this item, that error appears on finish. Edit another item, same error. Create an item, same error. and so on. Do not know how it happened but it has. I am guessing from what you guys are saying is find the column that is not needed and delete it yes? and this will make our problem go away? Quote Link to comment Share on other sites More sharing options...
Tonka Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error or you can just edit your insert query Quote Link to comment Share on other sites More sharing options...
Canjucks Posted October 23, 2008 Share Posted October 23, 2008 Re: Add or Edit new item error its all good I found a solution with a similar topic and gave me the solution and now all works fine http://criminalexistence.com/ceforums/i ... pic=3008.0 can be found on this link. Cheers to you all for helping us out :-D 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.