Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attributes: How do I fix this error message?


MaFunk

Recommended Posts

Hi,

 

I hired a coder to build this site http://www.colishcreations.com and it's having some problems - I'm hoping that one of you osc gurus can help me with this. Since then I've started building the osc sites on my own, but for now I still have this little problem site to fix and can't seem to figure the error out. I know the answer is probably staring me in the face, but I can't find it.

 

When my client tries to add attributes she gets this error:

1136 - Column count doesn't match value count at row 1

insert into products_attributes values ('', '43', '2', '3', '0', '+')

[TEP STOP]

 

Any ideas on how to fix?

This is how I read the attribute values

' ' - not sure what this refers to - it seems that this referes to a blank space in one of the value fields, but I can't figure out why. I think that the product ID should be coming up there

 

43 - Product Name

 

2 - Option Name

 

3 - Option Value

 

0 - Value Price

 

+ - Prefix

 

oh - one other thing. The attributes to the products that were originally added to the store can be modified just fine. However when my client tries to add attributes to the newly added products she gets the error message. She did a fine job adding the products so its not a problem there.

 

_________________

 

 

So do you have any ideas on how to fix this?

 

 

Thanks

MaFunk

Link to comment
Share on other sites

The '' is for the products_attributes_id, which is automatically generated. Thus one passes a null value to it.

 

It's saying that the number of columns in the table does not match the number of values that it's trying to insert. I would look up the table structure in something like phpMyAdmin and see if it's right.

 

The default looks like this:

CREATE TABLE `products_attributes` (
 `products_attributes_id` int(11) NOT NULL auto_increment,
 `products_id` int(11) NOT NULL default '0',
 `options_id` int(11) NOT NULL default '0',
 `options_values_id` int(11) NOT NULL default '0',
 `options_values_price` decimal(15,4) NOT NULL default '0.0000',
 `price_prefix` char(1) NOT NULL default '',
 PRIMARY KEY  (`products_attributes_id`)
) TYPE=MyISAM AUTO_INCREMENT=28;

Hth,

Matt

Link to comment
Share on other sites

$25 to first person that can fix this

 

Ok - It's been almost a week and the best that I get from the coders of this site are "It's not from an error that we made, but an osc problem/erro". Which is bull-sh*t since I don't have this problem with any other osc sites that I built on my own!!!! I'm just so peaved off at these people. Working with them was a nightmare and I had to fix a couple of obvious things that they screwed up!!! - like they didn't put permissions on the folder so that my client could make changes!!!

 

OK, enough ranting and raving. I need help. If you are a true guru, and think that can fix this, I'll pay $25 (via paypal) for the person that can make it happen. Just tell me which files you need to see. I'll send you the code. Then I'll make the updates myself.

 

please email me off-line in regard to this [email protected]

 

Cheers,

MaFunk

Link to comment
Share on other sites

Hi Matt,

 

I feel like such an idiot, but I don't know where I'm supposed to find the table strucuture. I've been told to go to phpmyadmin - but i'm clueless. I can open all the php files. Where do I find the table structure? Remember - I don't really know anything about databases. . .

Link to comment
Share on other sites

There are various ways to find the structure of a table - the easiest of which is usually phpMyAdmin.

 

Your host my have it installed already on your server and might be worth asking them. If not it is downloadable for free and reasonably straightforward to install.

 

Otherwise, if you have a shell account you can query the database from the command line. If your database isnt that large you could even do a dump of the database and find the structure in there.

 

I would recommend getting phpMyAdmin if you don't know much about databases as it really is simple to use.

 

In the meantime however make a new file on your server in the catalog directory and put:

 

<?php
require('includes/application_top.php');

$attributes_query = tep_db_query("select * from products_attributes where 1");
$attributes_result = tep_db_fetch_array( $attributes_query );
?>
<html><br>
<body>
<pre>
<?php print_r($attributes_result); ?>
</pre>
</body>
</html>

 

this will show the structure of product attributes.

 

You will no doubt find that the structure of your attributes table has changed from default and you will need to change your sql statement to reflect this.

Link to comment
Share on other sites

Hi meltus,

 

Thanks for the info. I will have to spend some time playing around with phpmyadmin.

 

Actually, before I read your post I had the problem fixed by Matt Fletcher. This is what he did:

________________

I renamed your non-working file to admin/products_attributes.php.orig and uploaded a replacement copy to admin/products_attributes.php. The only change I made was to add (products_id, options_id, options_values_id, options_values_price, price_prefix) and remove the '', so that the line now looks like this:

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['options_id'] . "', '" . $HTTP_POST_VARS['values_id'] . "', '" . $HTTP_POST_VARS['value_price'] . "', '" . $HTTP_POST_VARS['price_prefix'] . "')");

_________________

Link to comment
Share on other sites

  • 3 months later...

I have tried all the fixes and can get none to work. Can someone help out....the attributes copier works but when i use the products attributes and try to add by hand I get the following eror and I have tried ALL the fixes so far

 

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values ('', '33', '1', '6', '', '+')

 

[TEP STOP]

Link to comment
Share on other sites

Actually, before I read your post I had the problem fixed by Matt Fletcher. This is what he did:

________________

I renamed your non-working file to admin/products_attributes.php.orig and uploaded a replacement copy to admin/products_attributes.php. The only change I made was to add (products_id, options_id, options_values_id, options_values_price, price_prefix) and remove the '', so that the line now looks like this:

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['options_id'] . "', '" . $HTTP_POST_VARS['values_id'] . "', '" . $HTTP_POST_VARS['value_price'] . "', '" . $HTTP_POST_VARS['price_prefix'] . "')");

_________________

I think the fix for the problem I describe here is somewhere in this syntax, but I'm missing it somewhere....

Link to comment
Share on other sites

  • 11 months later...

I feel a little stupid here. Im reading your posts and I still cant figure it out. Ive got the same problem. Whenever Im trying to add product attributes I get the following error:

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values ('', '35', '9', '6', '0', '+')

 

[TEP STOP]

 

I really need to have this fixed, but Im not even sure where to check my structures. I do have phpmyadmin

 

Can anyone put me on the right path? Sorry. I havent got any DB background.

 

Thanks for everyones time,

 

M

**************************************

The Media Centre Experts

Sydney - Australia

**************************************

Link to comment
Share on other sites

Essentially, what the fix is (as I understand it):

 

Change the line:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['options_id'] . "', '" . $HTTP_POST_VARS['values_id'] . "', '" . $HTTP_POST_VARS['value_price'] . "', '" . $HTTP_POST_VARS['price_prefix'] . "')");

 

to include the columns that you are targeting. (you are trying to insert 6 columns of data, and there are not exactly 6 columns, so we're going to tell it which 6 we want).

 

Updated code:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix) values ('', '" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['options_id'] . "', '" . $HTTP_POST_VARS['values_id'] . "', '" . $HTTP_POST_VARS['value_price'] . "', '" . $HTTP_POST_VARS['price_prefix'] . "')");

Link to comment
Share on other sites

Thanks so much for your help.

One really STUPID question:

 

Where exactly do I go to change the code ?

 

Thanks again,

 

M

**************************************

The Media Centre Experts

Sydney - Australia

**************************************

Link to comment
Share on other sites

Thanks so much for your help.

One really STUPID question:

 

Where exactly do I go to change the code ?

 

Thanks again,

 

M

 

Oops, I hadn't realized that no one mentioned the file name. The code to be changed is in /admin/products_attributes.php

 

I'm looking at a stock copy of that file right now, and the line you're looking for is not exactly the same as mentioned (the post here must be based on old code).

 

So, I'll try and give you as much specifics as possible:

Line 61 says:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (''..........

 

you need to add the column names like this:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix) values (''..........

Link to comment
Share on other sites

THANKYOU SO VERY MUCH

You are a wealth of information :)

 

Thanks for Everyones time. I REALLY appreciate it

 

Regards,

 

M :thumbsup:

**************************************

The Media Centre Experts

Sydney - Australia

**************************************

Link to comment
Share on other sites

  • 2 years later...

Hi all,

 

This Error (as at bug-report 2186) appers to be re-imerging

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values ('', '38', '2', '11', '', '+')

 

[TEP STOP]

 

The line that I think would be relevant in my /catalog/admin/products_attributes.php (that has been amended for the globals patch) is

Line: 67

and reads

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

Would anyone have an answer to this problem?

 

Regards,

Peter

Australia

Link to comment
Share on other sites

  • 2 months later...
Hi all,

 

This Error (as at bug-report 2186) appers to be re-imerging

 

1136 - Column count doesn't match value count at row 1

 

insert into products_attributes values ('', '38', '2', '11', '', '+')

 

[TEP STOP]

 

The line that I think would be relevant in my /catalog/admin/products_attributes.php (that has been amended for the globals patch) is

Line: 67

and reads

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

Would anyone have an answer to this problem?

 

Regards,

Peter

Australia

I just recently DL'd 2.2 RC1... this bug is still in the code.

 

As I can best describe it: The bug is a combination of a bad line of code and a conflict with the DB table design. I edited the code to reflect the names of the individual columns to receive the data as well as the data that is inserted. In the insertion data, the first column data value being inserted was an empty value "" i.e. the first ','. this wound up being an invalid value to insert in any of the data fields. I dropped the ',' and the error(s) went away.

 

Don't know the exact line number, in the 60s... I did a "find" to locate it.

My edited code:

 tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

hope others might find this useful

Link to comment
Share on other sites

  • 4 months later...

Archived

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

×
×
  • Create New...