Jump to content
MakeWebGames

Add or Edit new item error


p_T_s

Recommended Posts

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.

Link to comment
Share on other sites

Guest Anonymous

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...