Title: SQL Error every minute
Last modified: October 19, 2023

---

# SQL Error every minute

 *  Resolved [mediawaypoint](https://wordpress.org/support/users/mediawaypoint/)
 * (@mediawaypoint)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/)
 *     ```wp-block-code
       $ tail -f php_error_log)DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, ai1ic_install, maybe_create_table[19-Oct-2023 14:38:56 UTC] WordPress database error Table 'lkr032_ai1ic' already exists for query CREATE TABLE LKr032_ai1ic (ai1ic_key VARCHAR(190) NOT NULL,ai1ic_secrets TEXT NOT NULL,ai1ic_time INT(10) UNSIGNED NOT NULL,PRIMARY KEY (ai1ic_key),KEY ai1ic_time (ai1ic_time))DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, ai1ic_install, maybe_create_table[19-Oct-2023 14:39:56 UTC] WordPress database error Table 'lkr032_ai1ic' already exists for query CREATE TABLE LKr032_ai1ic (ai1ic_key VARCHAR(190) NOT NULL,ai1ic_secrets TEXT NOT NULL,ai1ic_time INT(10) UNSIGNED NOT NULL,PRIMARY KEY (ai1ic_key),KEY ai1ic_time (ai1ic_time))DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, ai1ic_install, maybe_create_table[19-Oct-2023 14:40:46 UTC] WordPress database error Table 'lkr032_ai1ic' already exists for query CREATE TABLE LKr032_ai1ic (ai1ic_key VARCHAR(190) NOT NULL,ai1ic_secrets TEXT NOT NULL,ai1ic_time INT(10) UNSIGNED NOT NULL,PRIMARY KEY (ai1ic_key),KEY ai1ic_time (ai1ic_time))DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, ai1ic_install, maybe_create_table
       ```
   
 * It seems this code keeps being called every 1 minute which is failing each time.
   It looks like there is no code to check if the table already exists and so my
   error log is filling up minute by minute.
 * \wp-content\plugins\contact-form-7-image-captcha\includes\module-wpforms.php
 * It seems this check doesn’t seem to be working where it checks if a table exists,
   because it is still trying to run the code.
 *     ```wp-block-code
       /**
        * Backend: Create table to save hash with icon title
        */
       add_action('admin_init', 'ai1ic_install');
       function ai1ic_install()
       {
           global $wpdb;
   
           $sql = 'CREATE TABLE ' . ai1ic_table_name() . ' (
               ai1ic_key VARCHAR(190) NOT NULL,
               ai1ic_secrets TEXT NOT NULL,
               ai1ic_time INT(10) UNSIGNED NOT NULL,
               PRIMARY KEY  (ai1ic_key),
               KEY ai1ic_time (ai1ic_time)
           )
           ' . $wpdb->get_charset_collate();
   
           require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
   
           // Test: see if this will only create table if not exist https://developer.wordpress.org/reference/functions/maybe_create_table/
           maybe_create_table(ai1ic_table_name(), $sql);
       ```
   
 * I actually cloned this website into a live environment too but did notice issues
   with the installer complaining that tables were locked, this might have something
   to do with the plugin trying to constantly add a table during the backup. But
   this hasn’t happened before so given the recent install of this plugin, I expect
   it is isolated to this one.
 * Cheers
 * Kane
    -  This topic was modified 2 years, 7 months ago by [mediawaypoint](https://wordpress.org/support/users/mediawaypoint/).

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

 *  Plugin Author [hookandhook](https://wordpress.org/support/users/hookandhook/)
 * (@hookandhook)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17136646)
 * Hi [@mediawaypoint](https://wordpress.org/support/users/mediawaypoint/),
 * Thanks for all the details.
 * The function maybe_create_table() only creates the table if it does not exist,
   see official WP documentation: [https://developer.wordpress.org/reference/functions/maybe_create_table/](https://developer.wordpress.org/reference/functions/maybe_create_table/)
 * Something else which is strange is, that the function ai1ic_install() is called
   every minute. This function is only called on admin_init by the plugin. The plugin
   does not use any WP cron events. So I assume something else is calling this function
   every minute.
 * Therefore I think another plugin/theme might interfere. Can you try to deactivate
   all plugins and activate one after the other to hopefully find out more?
 *  Thread Starter [mediawaypoint](https://wordpress.org/support/users/mediawaypoint/)
 * (@mediawaypoint)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17138496)
 * Hi there,
 * Thanks for responding so quickly, yes that was what I thought re the function
   only trying to create when it doesn’t exist – I did have a read through the documentation
   and yet it is still trying to run the code so something about the code is not
   quite working correctly sadly.
 * As it happens, this is a fresh install of WordPress. It is running ACF pro, Duplicator,
   Contact Form 7 and your plugin. I have since turned off ACF and Duplicator for
   the process of elimination. I have also reverted to the default twenty-twentythree
   theme but the issue still exists.
 * As it happens, the error is not just happening every minute, but also whenever
   any of the admin backend pages are loaded.
 * I can email you a zip of the website if you like? Tested on my local machine 
   and a test environment, the error still persists.
   Regards,Kane
 *  Plugin Author [hookandhook](https://wordpress.org/support/users/hookandhook/)
 * (@hookandhook)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17139488)
 * Hi Kane, Sure please send me the zip: [https://wpimagecaptcha.com/contact/](https://wpimagecaptcha.com/contact/)
   The contact form does not offer attachments currently, but I will reply to you
   and you can then attach the zip file.
 *  Thread Starter [mediawaypoint](https://wordpress.org/support/users/mediawaypoint/)
 * (@mediawaypoint)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17151954)
 * For anyone who might have been following this thread, I contacted WPImageCaptcha
   and resolved the issue. The fix will be added to a future update but if you need
   the assist now because of the problem you are having the change was as follows:
 *     ```wp-block-code
       File: /includes/module-wpforms.php
       Row: 96
   
       Change from:
       $sql = 'CREATE TABLE ' . ai1ic_table_name() . ' (
   
       Into:
       $sql = 'CREATE TABLE IF NOT EXISTS ' . ai1ic_table_name() . ' (
       ```
   
 * Thanks for your help sorting this 🙂
 *  Plugin Author [hookandhook](https://wordpress.org/support/users/hookandhook/)
 * (@hookandhook)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17158434)
 * I have just released v3.3.10 which includes the fix of this issue.

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

The topic ‘SQL Error every minute’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7-image-captcha/assets/icon.svg?rev=2970465)
 * [Image CAPTCHA for Contact Form 7 and WPForms by HookAndHook (DSGVO/GDPR)](https://wordpress.org/plugins/contact-form-7-image-captcha/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-image-captcha/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-image-captcha/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-image-captcha/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-image-captcha/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-image-captcha/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [hookandhook](https://wordpress.org/support/users/hookandhook/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/error-every-minute/#post-17158434)
 * Status: resolved