Title: WordPress database error Duplicate entry
Last modified: August 21, 2016

---

# WordPress database error Duplicate entry

 *  Resolved [roshan.gade](https://wordpress.org/support/users/roshangade/)
 * (@roshangade)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/)
 * Hi Team,
 * I am using latest version of “iiRe Social Icons” plugin with WordPress Version(
   3.5.1), but when I re-installed iiRe Social Icons plugin, the wordpress starts
   throwing following two errors.
 * [Mon Jul 01 08:22:27 2013] [error] [client 111.111.111.111] WordPress database
   error Duplicate entry ’62’ for key ‘PRIMARY’ for query INSERT INTO wp_iire_social(
   option_id, option_name, option_value) VALUES (’62’, ‘widget_effect’, ”) made 
   by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘
   wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’),
   call_user_func_array, iire_update_social_check
 * [Mon Jul 01 08:22:27 2013] [error] [client 111.111.111.111] WordPress database
   error Duplicate entry ‘101’ for key ‘PRIMARY’ for query INSERT INTO wp_iire_social(
   option_id, option_name, option_value) VALUES (‘101’, ‘sc_effect’, ”) made by 
   require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘wp-
   config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’), call_user_func_array,
   iire_update_social_check
 * I deleted above duplicate database entries, but still showing same error.
 * Thanks,
    Roshan.
 * [http://wordpress.org/extend/plugins/iire-social-icons/](http://wordpress.org/extend/plugins/iire-social-icons/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892190)
 * Uninstalling should completely delete the table that saves all the plugin settings.
   Deactivation retains the settings. The upgrade from from versions add the two
   settings if they do not exist.
 * Try completely uninstalling.. I’ll see if there’s an issue updating on the current
   version.
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892195)
 * The inserts for sc-effect and widget_effect on only on an initial upgrade from
   a prior version (less than 1.6.0) and so far seem to be working fine on a new
   and existing plugin install from the WordPress.org site.
 * So far, I haven’t been able to replicate the database errors. It’s possible the
   install failed at some point and didn’t reset the version number.
 * You could possibly uninstall what you have, install a prior version ( 1.5.x),
   deactivate (this will remove everything), the install a fresh version of 1.6.0
 *  Thread Starter [roshan.gade](https://wordpress.org/support/users/roshangade/)
 * (@roshangade)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892244)
 * Hi Russell,
 * Thanks for your replies. I tried your both the solutions that you have said above,
   but still it didn’t work for me.
 * I installed a new wordpress on local machine and fresh version of iiRe Social
   Icons(1.6.0.), but I got the same errors. Then I edited “iire_social_install.
   php” file from plugin folder and changed INSERT query to REPLACE query and it
   works for me, and stopped showing errors.
 * Thanks,
    Roshan.
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892253)
 * Thanks for your feedback… I’ll try changing the insert to replace. The main issue
   is adding additional plugin parameters (the effects) without destroying the other
   saved parameters.
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892276)
 * Roshan, could you send me (webmaster at iireproductions dot com) a text file 
   of what you did on the install script?
 *  [Marco](https://wordpress.org/support/users/marcowegleiter/)
 * (@marcowegleiter)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892283)
 * Make sure you don’t use the debug mode:
    define(‘WP_DEBUG’, false); in wp-config.
   php
 *  Thread Starter [roshan.gade](https://wordpress.org/support/users/roshangade/)
 * (@roshangade)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892284)
 * Hi Russell,
 * I edited “**iire_social_install.php**” file from plugin folder and removed INSERT
   query from the middle part and at the bottom added the following REPLACE query.
 *     ```
       if (get_site_option('iire_social_data') < '1.6.0') {
       	$wpdb->query("REPLACE INTO $table (option_id, option_name, option_value) VALUES ('62', 'widget_effect', '')");
       	$wpdb->query("REPLACE INTO $table (option_id, option_name, option_value) VALUES ('101', 'sc_effect', '')");
       }
       ```
   
 * If you will see following if condition carefully in iire_social_install.php file,
   it already adds both rows i.e. 62 and 101.
 *     ```
       if (get_site_option('iire_social_data') == '0') {
       // INSERT queries
       }
       ```
   
 * For more info:
    The MySQL [**REPLACE**](http://www.mysqltutorial.org/mysql-replace.aspx)
   statement is a MySQL extension to the SQL standard. The MySQL REPLACE statement
   works like the INSERT statement with the additional rules:
    - If the record which you want to insert does not exist, the MySQL REPLACE inserts
      a new record.
    - If the record which you want to insert already exists, MySQL REPLACE deletes
      the old record first and then insert a new record.
 * Thanks,
    Roshan
 *  [Marco](https://wordpress.org/support/users/marcowegleiter/)
 * (@marcowegleiter)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892285)
 * I deactivated and deleted the plugin. Additionally I droped the SQL-table xxxiire_social.
   But there was still something about the plugin stored in the options table which
   prevented the plugin to save any information in the settings. So I used the plugin“
   Search and replaces” and searched for any left “iire”-entries. After I found 
   them I manually deleted those entries from the options table. I can save the 
   settings now again.
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892289)
 * Thanks for the input guys… The uninstall function is suppose to delete any iiRe
   options in the wp-options table as well as drop the “iire-social” settings table.
   The prior version did this on deactivation, but not on the latest upgrade as 
   most people want to retain there settings, which now seems to be causing the 
   occassional problem.
 * I’m considering making this an optional setting in my admin interface that is
   checked upon deactivation
 * If anyone has input on how to correctly remove a custom table on the WordPress
   uninstall call, I’d love to see it!
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892303)
 * Please try the latest [beta](http://iireproductions.com/wp-content/downloads/demos/iire_social_1.6.1/iire-social-icons.zip)
 * This version has the suggested MYSQL fixes and an option to remember settings.
   Go to the Widget Designer, General Settings, Remember Icons
 * Let me know if you find anything
 *  [ipmcorp](https://wordpress.org/support/users/ipmcorp/)
 * (@ipmcorp)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892424)
 * I am having the same issue. Using v. 1.6.1 on WP Version 3.8.1 MU enabled. Have
   been using the plugin for about two weeks.
 * I figured from this thread and the change log that this was figured out but no
   matter what I have done, it continues to try to create entries every page load
   and builds an error log (1 gig in a week)
 * [28-Mar-2014 11:40:25 UTC] WordPress database error for query CREATE TABLE IF
   NOT EXISTS wp_4_iire_social (
    option_id INT(11) NOT NULL AUTO_INCREMENT, option_name
   VARCHAR(255) NOT NULL, option_value LONGTEXT NOT NULL, PRIMARY KEY (option_id))
   made by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘
   wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’),
   call_user_func_array, iire_update_social_check, iire_social_install
 * [28-Mar-2014 11:40:25 UTC] WordPress database error Duplicate entry ‘1’ for key‘
   PRIMARY’ for query INSERT INTO wp_4_iire_social (option_id, option_name, option_value)
   VALUES (‘1’, ‘registration_email’, ”) made by require(‘wp-blog-header.php’), 
   require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-
   settings.php’), do_action(‘plugins_loaded’), call_user_func_array, iire_update_social_check
 * The error log continues to: ‘101’, ‘sc_effect’
 * When deactivated the tables won’t drop and the entries continue to duplicate,
   and again must manually drop them.
 * Deleted plugin and re-installed…and same same.
 * iire_social_install.php 7/14/2013
 * Am I missing something. I debugged this for hours and I am not seeing it.
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892425)
 * Are you trying to use the plugin on multiple MU sites? if so, you should install
   the plugin through the WordPress admin for each site, not the main admin… The
   tables are created for each site ID…
 * If you have access to the plugin admin, go to General Settings, turn the Remember
   My settings to “No”, then uninstall the plugin… This should remove all tables
   related to the plugin and any version entries in the wp_options table.
 * If you access to MYSQ, search the WP_OPTIONS table for anything with the prefix“
   iire_” any remove those.
 * Once everything is removed, reinstall the latest version of the plugin and you
   should be fine.
 *  [ipmcorp](https://wordpress.org/support/users/ipmcorp/)
 * (@ipmcorp)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892426)
 * Yes using the plugin on MU. Not possible to install on each site as the plugins
   on Multi-site are shared. Can activate individually of course instead of network
   activate. I wasn’t sure if that is what you meant ‘install’ vs ‘activate’.
 * So I did the steps as directed (which I did before by question).
    Disable save
   settings. Remove plugin entirely. (tables don’t drop) Remove tables (created 
   for each site id activated) Filter search iire just in case (no results) Ftp 
   the Plugin 1.6.1 Activate one site only id_8 Error Repeats each load.
 * [05-Apr-2014 12:05:26 UTC] WordPress database error for query CREATE TABLE IF
   NOT EXISTS wp_8_iire_social (
    option_id INT(11) NOT NULL AUTO_INCREMENT, option_name
   VARCHAR(255) NOT NULL, option_value LONGTEXT NOT NULL, PRIMARY KEY (option_id))
   made by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘
   wp-config.php’), require_once(‘wp-settings.php’), do_action(‘plugins_loaded’),
   call_user_func_array, iire_update_social_check, iire_social_install [05-Apr-2014
   12:05:26 UTC] WordPress database error Duplicate entry ‘1’ for key ‘PRIMARY’ 
   for query INSERT INTO wp_8_iire_social (option_id, option_name, option_value)
   VALUES (‘1’, ‘registration_email’, ”) made by require(‘wp-blog-header.php’), 
   require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-
   settings.php’), do_action(‘plugins_loaded’), call_user_func_array, iire_update_social_check(
   continues to 101)
 * Temporarily I have been deleting the error_log as it grows…
 * Any Idea? Thanks in advance
 *  Plugin Author [srussell13](https://wordpress.org/support/users/srussell13/)
 * (@srussell13)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892427)
 * Yes, it would be “install” once on the primary site and “activate” on the other
   MU sites. I would not activate on the primary.
 * In the WP-OPTIONS table, there are 3 “iire_social” items ( iire_social_data=1,
   iire_social_version=1.6.1, iire_social_saveparms=0) that store the version info
   when performing the upgrade. If you haven’t already, make sure these are removed
   or set to these values when testing/reinstalling
 * It appears, based on your latest info, the entries are trying to reinsert all
   field entries (101) each time on a page load, which it should not do. This usually
   is a versioning problem. I would give the above values a look in wp-options table
   for the primary and mu sites.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘WordPress database error Duplicate entry’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/iire-social-icons_e5c5ab.svg)
 * [iiRe Social Icons](https://wordpress.org/plugins/iire-social-icons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/iire-social-icons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/iire-social-icons/)
 * [Active Topics](https://wordpress.org/support/plugin/iire-social-icons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/iire-social-icons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/iire-social-icons/reviews/)

 * 14 replies
 * 4 participants
 * Last reply from: [srussell13](https://wordpress.org/support/users/srussell13/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-1/#post-3892427)
 * Status: resolved