• Hello

    I noticed from my server error log that the function that records the clicks on an attachment to the DB (/inc/eg-attachments-public.inc.php, line 202 and following) throws the following error:

    WordPress errore sul database Duplicate entry '2016-09-03 00:00:00-12816-12822' for key 'PRIMARY' per la query INSERT INTO wpat_eg_attachments_clicks (click_date,post_id,post_title,attach_id,attach_title,clicks_number) values (CURRENT_DATE(),12816,'Test Ingresso',12822, 'Potenze', 1) fatta da require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), call_user_func_array, EG_Attachments_Public->manage_link, EG_Attachments_Public->record_click

    This is because my WPDB table prefix isn’t the default value “wp_”, but “wpat_”.

    I suggest using the $wpdb->prefix var instead of the fixed string “wp_” in line 217 of the aforementioned file:
    $sql = $wpdb->prepare('SELECTclick_id,clicks_number FROM‘.$wpdb->prefix.’eg_attachments_clicks` WHERE click_date=CURRENT_DATE() AND attach_id=%d AND post_id=%d’,
    $attach_id, $parent_id);`

    Kind regards

    Kind regards

    • This topic was modified 8 years, 2 months ago by Andrea Riva.
  • The topic ‘Database error (duplicate keys) for click tracking’ is closed to new replies.