Jump to content
lelijk

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

Recommended Posts

Hi all!

I've installed Alternative attribute handling (putting attributes at the products page) and after this I've installed attributes sort order. From the attributes page I can assign attributes but when I do this from the products page, with alternative attribute handling, I get the error:

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

 

insert into products_attributes values ('', '1', '3', '6', '', '')

 

[TEP STOP]

 

I already know this has to do that within the database there are 7 columns and the script is putting 6 in..........

 

Already tried a couple of things but no luck.........i'm a designer and not a programmer...... :(

Can somebody PLEASE look this code and tell me what I have to do to get rid of this error?!

The code that had to use:

 

At line 264 add the following to get you to 290

 

> // Update Product Attributes

> $rows = 0;

> $options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");

> while ($options = tep_db_fetch_array($options_query)) {

> $values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");

> while ($values = tep_db_fetch_array($values_query)) {

> $rows ++;

> $attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");

> if (tep_db_num_rows($attributes_query) > 0) {

> $attributes = tep_db_fetch_array($attributes_query);

> if ($HTTP_POST_VARS['option'][$rows]) {

> if ( ($HTTP_POST_VARS['prefix'][$rows] <> $attributes['price_prefix']) || ($HTTP_POST_VARS['price'][$rows] <> $attributes['options_values_price']) ) {

> tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $HTTP_POST_VARS['price'][$rows] . "', price_prefix = '" . $HTTP_POST_VARS['prefix'][$rows] . "' where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

> }

> } else {

> tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

> }

> } elseif ($HTTP_POST_VARS['option'][$rows]) {

> tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "')");

> }

> }

> }

>

 

At line 616 find this

 

> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

> </tr>

> <tr>

 

add the following after it to get you to 676

 

> <td><table border="0" cellspacing="0" cellpadding="2">

> <tr valign="top">

> <?php

> $rows = 0;

> $options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");

> while ($options = tep_db_fetch_array($options_query)) {

> $values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");

> $header = false;

> while ($values = tep_db_fetch_array($values_query)) {

> $rows ++;

> if (!$header) {

> $header = true;

> ?>

> <td><table border="0" cellpadding="0" cellspacing="0">

> <tr class="dataTableHeadingRow">

> <td class="dataTableHeadingContent" colspan="3"><?php echo $options['products_options_name']; ?></td>

> </tr>

> <?php

> }

> $attributes = array();

> if (sizeof($HTTP_POST_VARS) > 0) {

> if ($HTTP_POST_VARS['option'][$rows]) {

> $attributes = array('products_attributes_id' => $HTTP_POST_VARS['option'][$rows],

> 'options_values_price' => $HTTP_POST_VARS['price'][$rows],

> 'price_prefix' => $HTTP_POST_VARS['prefix'][$rows]);

> }

> } else {

> $attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $pInfo->products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");

> if (tep_db_num_rows($attributes_query) > 0) {

> $attributes = tep_db_fetch_array($attributes_query);

> }

> }

> ?>

> <tr class="dataTableRow">

> <td class="dataTableContent"><?php echo tep_draw_checkbox_field('option[' . $rows . ']', $attributes['products_attributes_id'], $attributes['products_attributes_id']) . ' ' . $values['products_options_values_name']; ?> </td>

> <td class="dataTableContent"><?php echo tep_draw_input_field('prefix[' . $rows . ']', $attributes['price_prefix'], 'size="2"'); ?></td>

> <td class="dataTableContent"><?php echo tep_draw_input_field('price[' . $rows . ']', $attributes['options_values_price'], 'size="7"'); ?></td>

> </tr>

> <?php

> }

> if ($header) {

> ?>

> </table></td>

> <?php

> }

> }

> ?>

> </tr>

> </table></td>

> </tr>

> <tr>

 

At line 796 change this line

 

< if (!is_array($HTTP_POST_VARS[$key])) {

 

to these lines

 

> if (is_array($value)) {

> while (list($k, $v) = each($value)) {

> echo tep_draw_hidden_field($key . '[' . $k . ']', htmlspecialchars(stripslashes($v)));

> }

> } else {

 

Three lines below this you'll find this - delete it.

 

< $languages = tep_get_languages();

< for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {

< echo tep_draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']])));

< echo tep_draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']])));

< echo tep_draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']])));

< }

 

This is the database column:

 

ALTER TABLE products_attributes ADD COLUMN attribute_sort INT UNSIGNED NOT NULL DEFAULT '0';

 

THANKS IN ADVANCE!!

Chris

Share this post


Link to post
Share on other sites

It would be really nice if someone would post how to fix this error. I understand that the insert is only 7 values but needs to be 9. How and where do I add the other two. Sharing your fix with everyone is what this forum is all about. Thanks in advance.

Share this post


Link to post
Share on other sites

Hi, I am having the same problem, except that I don't have access to the database so I can't check how m,any columns are in it.

 

The fix should be to inser a '', in the array in the place where the new column is, probably at the end.

 

I figure I'd post this so that either I am right and I help someone or I am wrong and I'll piss someone off enough to post the right answer.

 

Cheers

Share this post


Link to post
Share on other sites

Found the answer buried deep in another thread..

 

Many thanks to Micha(II) - worked great for me :-)

 

In admin/categories.php search for:

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "')");

replace with:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . (int)$attributes_sort . "')");

Share this post


Link to post
Share on other sites
Found the answer buried deep in another thread..

 

Many thanks to Micha(II) - worked great for me :-)

 

In admin/categories.php search for:

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "')");

replace with:

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . (int)$attributes_sort . "')");

 

 

 

I cant find the code in 'admin/categories.php', anyone else know where it is?

Share this post


Link to post
Share on other sites
I cant find the code in 'admin/categories.php', anyone else know where it is?

 

 

its not in the admin/categories.php its in the admin/products_attributes.php

 

Look for this

 

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) . "')");

 

 

and replace with this

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . (int)$attributes_sort . "')");

Share this post


Link to post
Share on other sites
its not in the admin/categories.php its in the admin/products_attributes.php

 

Look for this

 

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) . "')");

and replace with this

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . (int)$attributes_sort . "')");

Thank you very much silvercue.

I add the same problem after installing add-weight-to-product-attributes v0.2

And now it is solved.

However, I noticed that I was unable to "insert" a new attribute for the 5 original options which are color, size, model, memory and version.

And it is the same for the options that I create myself.

I got to use the edit function to do so.....

But for the weight attributes it is possible !

Share this post


Link to post
Share on other sites

I have add-weight-to-product-attributes v0.2 and this is what I changed to remedy the proble

 

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

 

to

 

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

Share this post


Link to post
Share on other sites
its not in the admin/categories.php its in the admin/products_attributes.php

 

Look for this

 

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) . "')");

and replace with this

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "', '" . (int)$attributes_sort . "')");

 

 

Now I have this error again:

 

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

insert into products_attributes values ('', '89', '', '', '', '', '0')

[TEP STOP]

 

Help me.... :'(

Share this post


Link to post
Share on other sites
Now I have this error again:

 

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

insert into products_attributes values ('', '89', '', '', '', '', '0')

[TEP STOP]

 

Help me.... :'(

 

 

Me too!


Installed Modules:

Dynamenu, InfoBox Admin, Master Products v.1.2, Header Tags Controller, Multiple Products Manager, Quick Edit in Admin, Secure Admin, Ultimate SEO URL's, EZ Secure Order, Easy Populate v.2.76d MS2, AuthorizeNet_AIM, ChangeFinal Breadcrumb Title, FedEx Labels, Fedex Direct 2.06, How Did you Hear 1.5, Login a la Amazon, UPS XML 1.2.4, USPS Labels, USPS Methods API MS2

Share this post


Link to post
Share on other sites
I do as well...is there anyone that can help with this? Thanks!

 

For me works: dustins81's advise Thanks a lot ;)

 

Andrew

Share this post


Link to post
Share on other sites

Chalk up another crying user - same thing. I have no idea what to do and I cannot find any real fixes anywhere...

 

I am using Alternative_Attributes7 and getting

 

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

insert into products_attributes values ('', '481', '8', '1163', '', '')

[TEP STOP]

 

I don;t even know how to decipher the error to start looking - can anybody help?

Edited by oarenj

Share this post


Link to post
Share on other sites
Chalk up another crying user - same thing. I have no idea what to do and I cannot find any real fixes anywhere...

 

I am using Alternative_Attributes7 and getting

 

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

insert into products_attributes values ('', '481', '8', '1163', '', '')

[TEP STOP]

 

I don;t even know how to decipher the error to start looking - can anybody help?

 

 

Hi

 

Same problems here with the attribute sort contribution...

 

Anybody found a solution?

 

Thanks!

Share this post


Link to post
Share on other sites

Hi. Count me in on this problem. I've completly flushed all the attributes and even all the products and started again but to no avail.

 

Could someone please find out about this problem????

 

I'm getting the following error:

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

 

insert into products_attributes values (null, '0', '0', '0', '0', '+', '0','')

 

[TEP STOP]

Share this post


Link to post
Share on other sites

I was having the same problem and I found a solution.

 

admin/products_attributes (about line 76)

 

Find ..

 

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) . "')");

 

Replace that line with ..

 

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) . "')");

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) . "')");

 

WORKS FOR ME!!!

Edited by comquestcomputers

Share this post


Link to post
Share on other sites

the mod to admin/products_attributes.php

also worked for me with a small change to include the sort order:

 

//	  tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (null, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");
//	  tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (null, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$products_options_sort_order . "','')");
// 1136 - Column count doesn't match value count at row 1  insert into products_attributes values (null, '91', '11', '0', '0', '+', '0','')
	tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " 
( products_id,  options_id,  options_values_id,   options_values_price,	  price_prefix,  products_options_sort_order) 
values ('" .	 (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$products_options_sort_order . "')");

 

For an explanation of what causes this error have a look at

codingforums.com/archive/index.php?t-28471.html

Edited by amcho

Share this post


Link to post
Share on other sites

thank you so much!! I uninstalled 'quantity product mod' add on and begun having problems with adding original attributes. but replacing the code with this , went back to working normally!

 

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 this helps someone :)

 

x

Share this post


Link to post
Share on other sites

This worked for me

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . "

( products_id, options_id, options_values_id, options_values_price, price_prefix, attribute_sort)

values ('" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$attribute_sort . "')");

Share this post


Link to post
Share on other sites
This worked for me

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . "

( products_id, options_id, options_values_id, options_values_price, price_prefix, attribute_sort)

values ('" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$attribute_sort . "')");

 

I thought I'd add a follow up to this since I was pulling my hair out till I found this solution at the end of this post. I had installed the Attribute Sort w/ Attribute Clone contrib and was getting that same column count error. I took the code that Ben Walsh provided and placed it in admin/products_attributes.php.

 

I had to replace some of the code that I added as part of the Attibute Sort contrib, specifically:

 

 // BOE: Attribute Sort with Clone Tool

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

// EOE: Attribute Sort with Clone Tool

 

Find this in your code and replace it with the code Ben Walsh provided (above). Now I can add attributes without that error.

Share this post


Link to post
Share on other sites
I was having the same problem and I found a solution.

 

admin/products_attributes (about line 76)

 

Find ..

 

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) . "')");

 

Replace that line with ..

 

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) . "')");

 

WORKS FOR ME!!!

 

 

yup that one worked for me too......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×