Title: SQL syntax error in cron cleanup function.
Last modified: October 14, 2025

---

# SQL syntax error in cron cleanup function.

 *  [Akash Raj ST](https://wordpress.org/support/users/akashrajst/)
 * (@akashrajst)
 * [8 months ago](https://wordpress.org/support/topic/sql-syntax-error-in-cron-cleanup-function/)
 * There seems to be an SQL syntax issue occurring when a scheduled cron job runs
   a cleanup function in the plugin.
 * **Context:**
   Hook: `logichop_local_delete_storage`Function: `public static function
   delete()`File: `wp-content/plugins/logic-hop/includes/api/data.php` (Line: 201)
 * **Generated SQL:**
   `DELETE FROM wp_2_logichop_local_storage WHERE Updated < DATE_SUB(
   NOW(), INTERVAL '1 DAY')`
 * **Error (from `$wpdb->last_error`):**
   `You have an error in your SQL syntax; 
   check the manual that corresponds to your MySQL server version for the right 
   syntax to use near ')' at line 1`
 * **Root Cause:**
   `INTERVAL` in MySQL does not accept quoted values. However, when
   using `$wpdb->prepare()`, the value passed to `%s` gets automatically wrapped
   in quotes, leading to a syntax error.
 * It should be `... DATE_SUB(NOW(), INTERVAL 1 DAY`) instead of `... DATE_SUB(NOW(),
   INTERVAL '1 DAY'`). It appears that this issue was introduced in version 3.9.1.
 * Due to this SQL syntax error, the cleanup process is not executed. Could you 
   please check this issue ? Thank you.
    -  This topic was modified 8 months ago by [Akash Raj ST](https://wordpress.org/support/users/akashrajst/).

The topic ‘SQL syntax error in cron cleanup function.’ is closed to new replies.

 * ![](https://ps.w.org/logic-hop/assets/icon-256x256.png?rev=1914075)
 * [Logic Hop - Dynamic Content Personalization for WordPress](https://wordpress.org/plugins/logic-hop/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/logic-hop/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/logic-hop/)
 * [Active Topics](https://wordpress.org/support/plugin/logic-hop/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/logic-hop/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/logic-hop/reviews/)

## Tags

 * [cleanup](https://wordpress.org/support/topic-tag/cleanup/)
 * [cron](https://wordpress.org/support/topic-tag/cron/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 0 replies
 * 1 participant
 * Last reply from: [Akash Raj ST](https://wordpress.org/support/users/akashrajst/)
 * Last activity: [8 months ago](https://wordpress.org/support/topic/sql-syntax-error-in-cron-cleanup-function/)
 * Status: not resolved