Title: Database error
Last modified: November 4, 2019

---

# Database error

 *  Resolved [Tofandel](https://wordpress.org/support/users/tofandel/)
 * (@tofandel)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/database-error-300/)
 * In `wp-optimize\vendor\team-updraft\common-libs\src\updraft-tasks\class-updraft-
   task.php` on line 332
 * You have the following syntax error
 *     ```
       $affected = $wpdb->query($wpdb->prepare("
       	UPDATE {$wpdb->base_prefix}tm_tasks
       	SET last_locked_at = %d'
       	WHERE id = %d
       	AND last_locked_at <= %s
       ", time(), $task_id, $expires_at));
       ```
   
 * Notice the single quote after the %d but not before
 * It causes errors during cron updates
 * The correct code should be
 *     ```
       $affected = $wpdb->query($wpdb->prepare("
       	UPDATE {$wpdb->base_prefix}tm_tasks
       	SET last_locked_at = %d
       	WHERE id = %d
       	AND last_locked_at <= %s
       ", time(), $task_id, $expires_at));
       ```
   
    -  This topic was modified 6 years, 7 months ago by [Tofandel](https://wordpress.org/support/users/tofandel/).

Viewing 1 replies (of 1 total)

 *  [Marc Lacroix](https://wordpress.org/support/users/marcusig/)
 * (@marcusig)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/database-error-300/#post-12095624)
 * Hi,
 * Thanks for reporting this in detail! Appreciate it.
    We’ll fix this.
 * Marc.

Viewing 1 replies (of 1 total)

The topic ‘Database error’ is closed to new replies.

 * ![](https://ps.w.org/wp-optimize/assets/icon-256x256.png?rev=1552899)
 * [WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance](https://wordpress.org/plugins/wp-optimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-optimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-optimize/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-optimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-optimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-optimize/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Marc Lacroix](https://wordpress.org/support/users/marcusig/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/database-error-300/#post-12095624)
 * Status: resolved