Title: [Plugin: Events Manager] SQL error on event-save
Last modified: August 20, 2016

---

# [Plugin: Events Manager] SQL error on event-save

 *  [halifaxious](https://wordpress.org/support/users/halifaxious/)
 * (@halifaxious)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/)
 * Hi,
 * The following error occurred with both events-manager 5.0.50 and 5.0.51:
 *     ```
       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 '' at line 1]
       SELECT event_id FROM wp_em_events WHERE event_id=
       ```
   
 * This does not happen when updating existing events. The last successful event
   posting was on January 10. It would have been done using the most recent version
   of event-manager available at that time.
 * Does anyone know if this is a bug or a conflict with another plugin? To me, it
   appears that the query wants to use an `event_id` that should have been generated
   by an `INSERT` query and that no such id is available.
 * Suggestions?
 * Thanks,
    Jen
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

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

 *  [agelonwl](https://wordpress.org/support/users/angelonwl/)
 * (@angelonwl)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526124)
 * Like what you said, it could be a plugin conflict or a theme issue; You can try
   to deactivate other plugins or revert to default theme. Also, can you provide
   more details such as installed plugin, theme or if its in multisite mode.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526137)
 * is this when you create a new event?
 *  Thread Starter [halifaxious](https://wordpress.org/support/users/halifaxious/)
 * (@halifaxious)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526228)
 * Hi Marcus,
 * Yes, it only happens when I try to create a new event. Both the ‘save draft’ 
   and the ‘Publish’ buttons will cause it.
 * Site details:
    Theme: Suffusion with child theme multisite: NO WP version: 3.3.1
 * Cheers,
    Jen
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526242)
 * Not sure what’d cause this. I’d try disabling your plugins and use the 2011 theme
   to see if any of these are causing it.
 *  Thread Starter [halifaxious](https://wordpress.org/support/users/halifaxious/)
 * (@halifaxious)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526252)
 * I disabled all plugins except Event Manager and tried the 2011 theme. The problem
   still occurs.
 * One thing I did notice, is that all the test events I’ve been creating actually
   do end up in the Events list (both admin and on the calendar). So the SQL error
   is more alarming than harmful.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526258)
 * could be, but would be nice to avoid it….
 * Is WP_DEBUG on for you in wp-config.php (you should turn it off if you’re on 
   a production site)? I tried creating an event with it enabled and didn’t duplicate
   this.
 *  Thread Starter [halifaxious](https://wordpress.org/support/users/halifaxious/)
 * (@halifaxious)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526264)
 * I’d forgotten I had WP_DEBUG==true. Turning it off does fix the immediate issue
   in an ‘out of sight, out of mind’ sort of way.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526305)
 * I usually develop with WP_DEBUG on, so usually this doesn’t happen… If we can
   find the pattern as to why it happens it would probably be an easy fix.
 *  [webdsgndotme](https://wordpress.org/support/users/webdsgndotme/)
 * (@webdsgndotme)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526402)
 * Try patching events-manager/classes/em-event.php with the folling:
 *     ```
       583c583,587
       < 			$event_truly_exists = $wpdb->get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$this->event_id}") == $this->event_id;
       ---
       >       if (empty($this->event_id)) {
       >         $event_truly_exists = false;
       >       } else {
       >         $event_truly_exists = $wpdb->get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_id={$this->event_id}") == $this->event_id;
       >       }
       ```
   
 * The error is raising when the event_id property of the EM_Event object is empty,
   and so the query fails.
 *  Plugin Author [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * (@netweblogic)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526403)
 * agreed, thx for fix

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

The topic ‘[Plugin: Events Manager] SQL error on event-save’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 10 replies
 * 4 participants
 * Last reply from: [Marcus (aka @msykes)](https://wordpress.org/support/users/netweblogic/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-events-manager-sql-error-on-event-save/#post-2526403)
 * Status: not resolved