Author Topic: Image - Replace Thumb sql error  (Read 858 times)

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Image - Replace Thumb sql error
« on: May 16, 2016, 14:03:40 pm »
Hello,

I am getting a sql error when I try to replace the thumbnail image on an item.

 1062 Duplicate entry '0-5428' for key 'virtuemart_product_id' SQL=INSERT INTO `jos_virtuemart_product_medias` (`virtuemart_product_id`,`virtuemart_media_id`,`ordering`) VALUES ('','5428','1')

Any suggestions what I can do to repair this ?

Thanks

tommo27

  • Beginner
  • *
  • Posts: 6
  • A beginner
Re: Image - Replace Thumb sql error
« Reply #1 on: June 17, 2016, 02:40:01 am »
Hi Shimon,

Without looking into it more, it would appear that the SQL you're running should be an update statement, not insert.  The error you're getting tells you that the unique ID you're trying to insert into the database has already being used (it's already in there) and you can only use each unique ID once only.  The statement below will accomplish the task that needs to be done (updating the image thumbnail field):

Code: [Select]
UPDATE jos_virtuemart_product_medias SET virtuemart_media_id = '5428', ordering='1' WHERE virtuemart_product_id = '<ID of the product to be updated>'
If possible, turn on debug mode within the system section of global configuration and re-run the action that generates this error.  You should notice this time a stack trace which will allow us to follow the the calls and find out what we need to change.

Are you getting this error after an update, modification or extension installation etc or is this custom code you have written?