Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

1062 - Duplicate entry '' for key 1


muligruber

Recommended Posts

When I try to add a product I get the following error..

 

1062 - Duplicate entry '' for key 1

 

insert into products (products_quantity, products_model, products_price, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_image, products_date_added) values ('999', '001', '54.95', null, '', '1', '0', '1', 'Angels_035.jpg', now())

 

[TEP STOP]

 

 

any ideas?

Link to comment
Share on other sites

CREATE TABLE `products` (

`products_id` varchar(255) NOT NULL default '',

`products_quantity` varchar(255) default NULL,

`products_model` varchar(255) default NULL,

`products_image` varchar(255) default NULL,

`products_price` varchar(255) default NULL,

`products_date_added` varchar(255) default NULL,

`products_last_modified` varchar(255) default NULL,

`products_date_available` varchar(255) default NULL,

`products_weight` varchar(255) default NULL,

`products_status` varchar(255) default NULL,

`products_tax_class_id` varchar(255) default NULL,

`manufacturers_id` varchar(255) default NULL,

`products_ordered` varchar(255) default NULL,

PRIMARY KEY (`products_id`)

) TYPE=MyISAM

Link to comment
Share on other sites

Hmmm. What contributions have you installed?

 

This line right here is why it's happening:

 

`products_id` varchar(255) NOT NULL default '',

 

products_id is set as the primary key, which means there can be no duplicates in that field, hence the error. The problem is that products_id should be an int auto_increment field, not a varchar. How many products do you have in your database?

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

I tryed to set the products ID as auto incriment but it wont let me. I have 5223 products. I did not set this up I am trying to fix this from a customers current site.

 

I have been putting in product for them through phpmyadmin but I need to get this insert product fixed so the customer can do this for themselves.

 

I use something like

 

INSERT INTO `products` VALUES ('1530', '999', '530', './Products/MLB/Braves_039.jpg', '9.99', '', '', '', '', '1', '', '1', NULL);

Link to comment
Share on other sites

Well, the products that already exist have products_ids, and those are mapped to other tables, so you don't want to just change the column willy-nilly. You'll need to manually generate and insert ids. The statement you're using to insert new products expects that the products_id field is auto_increment.

Contributions

 

Discount Coupon Codes

Donations

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...