...

View Full Version : Error in column count?



masterofollies
12-31-2007, 04:56 AM
What does this error mean and what's the most likely thing that is causing it?

Column count doesn't match value count at row 1

oesxyl
12-31-2007, 05:07 AM
What does this error mean and what's the most likely thing that is causing it?

Column count doesn't match value count at row 1

http://htmlfixit.com/cgi-tutes/tutorial_MySQL_Error_Invalid_Query_Column_Count_Does_Not_Match_Value_Count.php

http://bugs.mysql.com/bug.php?id=21774

best regards

masterofollies
12-31-2007, 05:20 AM
I understand what it means from that top site. But I even uploaded an old copy that has no errors and im still getting it. So it must be in the database.

oesxyl
12-31-2007, 05:34 AM
I understand what it means from that top site. But I even uploaded an old copy that has no errors and im still getting it. So it must be in the database.

- check mysql version and look to the second link
- I don't know how upgrade/downgrade could affect the tables and databeses, could be something wrong that can't be revert
- upgrade to the last installed version and post the query maybe we can fix it

best regards

masterofollies
12-31-2007, 06:53 AM
This adds it to the database


$add = doquery("INSERT INTO {{table}} VALUES ('', '$userrow[id]', '$type', '$item', '$_POST[price]', '". time() . "', '$end', '" . addslashes($_POST[comments]) . "')", "market");


After you get the error and refresh or click back on your browser. The following code happens


if (mysql_num_rows($result) != 1) {
$page .= "<table width='100&#37;' border='1'><tr><td class='title'>Market - Buy Error</td></tr></table><br />
Sorry, but the item you attempted to purchase is no longer on the market. Perhaps it has already been sold. <br />
<br />
You may return to the <a href='index.php?do=market'>market</a>, <a href='index.php'>previous page</a>.";

display($page, "Buy Error");

exit;
}

Additional Information:

MySQL version 5.0.37-standard-log
PHP version 5.2.5

Also in the database in the market table. It says LIMIT(0,200)
the market was at 202 listings.
Do you think this limit thing is messing it up? It is on phpmyadmin and I even erased all listings and started back from nothing and uploaded an older bug free copy and it continues to have that error.

masterofollies
12-31-2007, 07:23 AM
I finally fixed it. There was a new field in a different table that was blank, and it was connected to this table in the script. So I deleted the field in the other table and everything works again. Thanks for the help

oesxyl
12-31-2007, 07:31 AM
This adds it to the database


$add = doquery("INSERT INTO {{table}} VALUES ('', '$userrow[id]', '$type', '$item', '$_POST[price]', '". time() . "', '$end', '" . addslashes($_POST[comments]) . "')", "market");




Additional Information:

MySQL version 5.0.37-standard-log
PHP version 5.2.5

Also in the database in the market table. It says LIMIT(0,200)
the market was at 202 listings.
Do you think this limit thing is messing it up? It is on phpmyadmin and I even erased all listings and started back from nothing and uploaded an older bug free copy and it continues to have that error.

- you have 9 fields in the table? If the script works before upgrade and if you don't change the table structure, the question is useless and the only explanation is a bug in mysql
- what's happend if you run this query, with the same value what generate the error, from phpmyadmin or direct into mysql?
- I don't see any limit in your query, where did it come from, phpmyadmin?
- I don't use phpmyadmin but I presume that limit(0,200) is a limitation only for manual query. If you increase this limits I suppose that only the manual query would be affected.

PS: I'm glad you fix it., :)

best regards and happy new year

Inigoesdr
12-31-2007, 09:52 AM
I know you solved it, but part of the problem is not listing the fields in the query. MySQL assumes that the values go into the table fields in the order they are in the query.
So, for example, if your table has 4 fields:

id, name, setting, etc
And you don't list them in the query:

INSERT INTO `table` VALUES ('', 'test', '123', '456');[code]
MySQL will try to insert '' into id(that should be NULL by the way), 'test' into name, '123' into setting, and '456' into etc. But If you change the number of fields, or add a field at the end of the table that doesn't have a default value, it will cause an error. So, you'll want to use a query like this:
[code]INSERT INTO `table` (`id`, `name`, `setting`, `etc`) VALUES(NULL, 'name', '123', '456');
And you should have fewer problems like this. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum