Title: Uncaught mysqli_sql_exception: Duplicate entry
Last modified: January 23, 2022

---

# Uncaught mysqli_sql_exception: Duplicate entry

 *  Resolved [mathse](https://wordpress.org/support/users/mathse/)
 * (@mathse)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/)
 * Hello,
 * I use koko analytics for quite some time (over 1 year) on my blog without any
   issues. Recnetly I git an error, when opening the “Analytics page” – I don’t 
   remember the error message in detail, but it was something like: “an uncaught
   error occured. Please contact your administrator”.
    After reloading the page 
   everything works as expected.
 * On my server I see the following error at the time in my logs:
 *     ```
       Nginx [2969]: 2022/01/23 21:37:46 [error] 37#37: *5163798 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught mysqli_sql_exception: Duplicate entry 'https://r.search.yahoo.com/_ylt=AwrXXXXXXXX.;_ylu=Y2' for key 'wp_koko_analytics_referrer_urls.url' in /var/www/html/wp-includes/wp-db.php:2056
       Nginx [2969]: Stack trace:
       Nginx [2969]: #0 /var/www/html/wp-includes/wp-db.php(2056): mysqli_query()
       Nginx [2969]: #1 /var/www/html/wp-includes/wp-db.php(1945): wpdb->_do_query()
       Nginx [2969]: #2 /var/www/html/wp-content/plugins/koko-analytics/src/class-aggregator.php(198): wpdb->query()
       Nginx [2969]: #3 /var/www/html/wp-includes/class-wp-hook.php(303): KokoAnalytics\Aggregator->aggregate()
       Nginx [2969]: #4 /var/www/html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
       Nginx [2969]: #5 /var/www/html/wp-includes/plugin.php(470): WP_Hook->do_action()
       Nginx [2969]: #6 /var/www/html/wp-content/plugins/koko-analytics/src/class-admin.php(111): do_action()
       Nginx [2969]: #7 /var/www/html/wp-includes/class-wp-hook.php(303): KokoAnalytics\Admin->show_page()
       Nginx [2969]: #8 /var/www/html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
       Nginx [2969]: #9 /var/www/html/wp-includes/plugin.php(470): WP_Hook->do_action()
       Nginx [2969]: #10 /var/www/html/wp-admin/admin.php(259): do_action()
       Nginx [2969]: #11 /var/www/html/wp-admin/index.php(10): require_once('/var/www/html/w...')
       Nginx [2969]: #12 {main}
       Nginx [2969]:   thrown in /var/www/html/wp-includes/wp-db.php on line 2056" while reading upstream, client: XX.XX.XX.XX, server: MYSERVER.net, request: "GET /wp-admin/index.php?page=koko-analytics HTTP/1.0", upstream: "fastcgi://XX.XX.XX.XX:9000", host: "MYSERVER.net", referrer: "MYREFERRER"
       ```
   
 * I use WordPress 5.8.3 with PHP 8.1.1.
    Maybe someone can help me here with this?
 * Thanks and greetings
 * Mathse

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

 *  Plugin Support [Lap](https://wordpress.org/support/users/lapzor/)
 * (@lapzor)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15284322)
 * Strange!
 * Do you have direct access to your database, eg via PhpMyAdmin?
    Maybe you can
   manually correct the issue there, although that still wouldn’t explain what caused
   it in the first place…
 *  Thread Starter [mathse](https://wordpress.org/support/users/mathse/)
 * (@mathse)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15284371)
 * Hello,
 * yes, I have direct access to the database, but the error rarely occurs (I just
   got it 2 times during the last weeks). So I don’t know if I should really change
   the database by hand?
 * Greetings and thanks for the support
 * Mathse
 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15287469)
 * Hello,
 * We’ve just released an update to the plugin (version 1.0.29) in which this issue
   should be addressed.
 * Hope that helps!
 *  Thread Starter [mathse](https://wordpress.org/support/users/mathse/)
 * (@mathse)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15288634)
 * Wow!!! That was fast – and unexpected.
    Thank you so much for this quick help
   and fix. I just installed the update (and hope the error is gone). Since I rarely
   saw the error before, I’m not quite sure yet, but since you say it’s fixed, I’m
   quite optimistic.
 * Thank you so much for this great Plugin and the great support here!
 * Greetings
 * Mathse
 *  Plugin Support [Lap](https://wordpress.org/support/users/lapzor/)
 * (@lapzor)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15289268)
 * Do let us know if the issue comes up again anyway. Thanks!
 *  [brahimalloud](https://wordpress.org/support/users/brahimalloud/)
 * (@brahimalloud)
 * [4 years ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15679482)
 * Hello my friend i wish you all the best i may have the solution to your problem,
   maybe i think its because that you made the attribut “wp_koko_analytics_referrer_urls.
   url”
    you need to disable unique constraint from it or raise an exception in 
   php to avoid the error and show the user an suitable error for this problem so
   he can avoid typing in an duplicate value
 *  Plugin Support [Lap](https://wordpress.org/support/users/lapzor/)
 * (@lapzor)
 * [4 years ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15680590)
 * hi [@brahimalloud](https://wordpress.org/support/users/brahimalloud/) , did you
   already update your koko plugin? what version of koko Analytics are you using
   currently where you are experiencing this issue? Thanks for letting me know.

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

The topic ‘Uncaught mysqli_sql_exception: Duplicate entry’ is closed to new replies.

 * ![](https://ps.w.org/koko-analytics/assets/icon.svg?rev=2980600)
 * [Koko Analytics - Privacy-Friendly WordPress Analytics](https://wordpress.org/plugins/koko-analytics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/koko-analytics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/koko-analytics/)
 * [Active Topics](https://wordpress.org/support/plugin/koko-analytics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/koko-analytics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/koko-analytics/reviews/)

 * 7 replies
 * 4 participants
 * Last reply from: [Lap](https://wordpress.org/support/users/lapzor/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/uncaught-mysqli_sql_exception-duplicate-entry/#post-15680590)
 * Status: resolved