Title: Syntax error (%d not replaced)
Last modified: August 22, 2016

---

# Syntax error (%d not replaced)

 *  Resolved [Luis Rodrigues](https://wordpress.org/support/users/goblindegook/)
 * (@goblindegook)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/)
 * I’ve been getting the following error recently:
 * `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 '%d ORDER BY created_on
   ASC LIMIT 4729'`
 * This is caused by the following query, which doesn’t replace the %d token:
 * `SELECT * FROM wp_wsal_occurrences WHERE created_on < %d ORDER BY created_on 
   ASC LIMIT 4729`
 * [https://wordpress.org/plugins/wp-security-audit-log/](https://wordpress.org/plugins/wp-security-audit-log/)

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

 *  Plugin Support [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5448972)
 * HI Luis,
 * Thank you for using our plugin and sorry to see you are encountering problems.
 * Can you please give me a bit of an overview about your problem by answering my
   questions?
 * 1. Is it a new install or an upgrade?
    2. It used to work before and it stopped
   during an upgrade? 3. When are you exactly getting this error, i.e. what are 
   you trying to access?
 * Looking forward to hearing from you.
 *  Thread Starter [Luis Rodrigues](https://wordpress.org/support/users/goblindegook/)
 * (@goblindegook)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5448986)
 * Hi Robert,
 * To answer your questions:
 * 1. This is an upgrade. I haven’t yet tried uninstalling and reinstalling the 
   plugin, didn’t seem to me it would solve a token replacement issue, but I can
   do it anyway.
 * 2. I’ve had query issues with this plugin in the past (mostly queries not supported
   by the database engine), but it’s the first time I’ve encountered this one.
 * 3. I have to get back to you on this later if you need specifics, but one of 
   the situations that triggers this error is when running a cron job (initiated
   by a crontab script rather than an HTTP request to WordPress).
 * Thanks!
 *  Plugin Support [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5448991)
 * Hi Luis,
 * Thank you for the details. It would be good if you can get back to me with more
   information though we will still look into what this issue could be.
 * Will keep you posted.
 *  [Tigr](https://wordpress.org/support/users/tigr/)
 * (@tigr)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449185)
 * Can you already fix it, please? The logs are filling up with the errors:
 *     ```
       WordPress database 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
       '%d ORDER BY created_on ASC LIMIT  1470'
       at line 1 for query
       SELECT * FROM x_wsal_occurrences WHERE created_on < %d
       ORDER BY created_on ASC LIMIT  1470
       made by do_action_ref_array, call_user_func_array,
       WpSecurityAuditLog->CleanUp, call_user_func,
       WSAL_Loggers_Database->CleanUp, WSAL_DB_OccurrenceQuery->Delete
       ```
   
 *  [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * (@wpwhitesecurity)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449186)
 * HI Tigr this is a separate issue from what Luis reported hence can you please
   open a separate ticket?
 * Having said that we were not able to reproduce any of the issues mentioned about
   hence these must be specific to your scenarios, maybe there is a conflict with
   another plugin or so.
 * Therefore can you please contact us on [support@wpwhitesecurity.com](https://wordpress.org/support/topic/syntax-error-d-not-replaced/support@wpwhitesecurity.com?output_format=md)
   so we can look further into each issue?
 * Looking forward to hearing from you.
 *  [Tigr](https://wordpress.org/support/users/tigr/)
 * (@tigr)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449189)
 * Right. Removed the plugin, dropped the tables with audit and wsal, removed all
   options with wsal in them. Reinstalled the plugin, now seems to work without 
   errors. There must be something messed up sometimes during update, that’s why
   you cannot reproduce it.
 *  [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * (@wpwhitesecurity)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449190)
 * HI Tigr,
 * I am glad your issue is solved. By the way we do test updates as well.
 * Thanks for the update.
 *  [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * (@wpwhitesecurity)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449208)
 * HI Luis Rodrigues,
 * We will have a fix for your issue in the next update of the plugin. Thanks for
   reporting it and stay tuned with us.
 * The next update should be available early next week.
 *  [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * (@wpwhitesecurity)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449216)
 * Hi Tigr,
 * We have a fix for your issue as well. Can you please drop us an email on [support@wpwhitesecurity.com](https://wordpress.org/support/topic/syntax-error-d-not-replaced/support@wpwhitesecurity.com?output_format=md)
   so we can send you an interim build for further testing?
 * Looking forward to hearing from you.

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

The topic ‘Syntax error (%d not replaced)’ is closed to new replies.

 * ![](https://ps.w.org/wp-security-audit-log/assets/icon-256x256.png?rev=2961534)
 * [WP Activity Log](https://wordpress.org/plugins/wp-security-audit-log/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-security-audit-log/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-security-audit-log/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-security-audit-log/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-security-audit-log/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-security-audit-log/reviews/)

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [SQL syntax](https://wordpress.org/support/topic-tag/sql-syntax/)

 * 9 replies
 * 4 participants
 * Last reply from: [WPWhiteSecurity](https://wordpress.org/support/users/wpwhitesecurity/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/syntax-error-d-not-replaced/#post-5449216)
 * Status: resolved