Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attribute Error


iberonurite

Recommended Posts

I´m having this error on the "Products Attributes"

 

1366 - Incorrect integer value: '' for column 'products_attributes_id' at row 1

 

insert into products_attributes values ('', '74', '1', '2', '', '+')

 

[TEP STOP]

 

What´s wrong?

 

Thank´s

Link to comment
Share on other sites

I´m having this error on the "Products Attributes"

 

1366 - Incorrect integer value: '' for column 'products_attributes_id' at row 1

 

insert into products_attributes values ('', '74', '1', '2', '', '+')

 

[TEP STOP]

 

What´s wrong?

 

Thank´s

 

 

Looks like no one has replied to your question is a few days, I just experienced the same issue. It appears to be a problem with the SQL statement it self. I'm running MySQL 5.045 with PHP 5.2.3 and Apache 2.2.

 

The problem for me occurs every time the code try's to insert nothing into an auto incrementing column in the database.

 

I corrected it by changing the following line of code in ./catalog/admin/products_attributes.php -- (approx line 61)

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

 

 

to the following

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

 

Seems to work very nicely now,

 

HTH

Jim

Link to comment
Share on other sites

  • 2 weeks later...

Jim,

 

I am getting the same error.

I don't know a thing about PHP, but I am a Data Architect, so know a good deal about data models, hence was hesitant to try out your solution.

By setting the id in the PRODUCT_ATTRIBUTES table to NULL, it should fail, as that is the primary key on that table and hence NOT NULL. So not sure how it worked for you.

 

I don't know how Mysql generates an auto incrementing number, but that's what should go in here. In Oracle, you can use a sequence that Oracle generates and maintains uniqueness. Here the least that would have to be done is that you pick the last value for product_attributes_id and increment that and add that to the table, assuming the previous set of id's were sequentially generated.

 

I looked at how they did it on the PRODUCT_OPTIONS table, and did something similar and then queried the database table PRODUCT_ATTRIBUTES and it's working fine.

 

So this is what I did, just above line 55 I added

 

       $products_attributes_id = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_id']);

 

And on the insert statement on line 61 in the values section, between the first single quote I added

 

" . (int)$products_attributes_id . "

 

This then properly generates the next higher number for product_attributes_id.

 

This is the entire original piece of code from line 54 to 61

 

      
     case 'add_product_attributes':
       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);
       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);
       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);
       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

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

 

This is the final edited coded.

 

     case 'add_product_attributes':
/* added the first line below */        
       $products_attributes_id = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_id']);
       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
       $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);
       $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);
       $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);
       $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

/* added the first text in the values bracket below */
       tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('" . (int)$products_attributes_id . "', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

 

Nevertheless this products_attributes has other bugs.

 

When you have PRODUCT_OPTIONS and PRODUCT_OPTIONS_VALUES more than what will fit on one page and you click on the >> arrow, it never scrolls through.

 

And the other biggest data integrity error is that when inserting a row in PRODUCT_ATTRIBUTES, it should do a check against PRODUCT_OPTIONS_VALUES_TO_PRODUCT_OPTIONS table to see the combination of Product_option and Value you are choosing makes sense.

 

For example, on this page, on the top when you add a new Option of Color and add a value of Red to it, it should not let you then add this Option of Color to a product and let you choose a value of 16 MB !! That does not make sense, as 16 Mb is a valid value only for the Memory PRODUCT_OPTION.

 

I hope I am making sense here and whoever developed this particular page for OsCommerce, looks into this.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...