Support » Plugin: Events Manager » Table … em_events doesn’t exist

  • Resolved Jay Collier

    (@jcollier)


    I installed Events Manager version 5.9.5, and tried creating an event. I received this error:

    Something went wrong saving your event to the index table. Please inform a site administrator about this.

    The console showed this: Table (snip)_em_events doesn't exist

    There are no tables with em or events in their names.

    I disabled and deleted the plugin, then reinstalled. Same problem. I disabled all plugins and changed the theme to Twenty-Nineteen. I searched the community forum with no luck/

    Have you seen this before? What should I do?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I did see this thread … https://wordpress.org/support/topic/tables-not-created-3/ … but I’m not sure how I would run this script to install the tables.

    I found an old backup of the site when I had been testing Events Manager and copied over the em_ tables. Working fine.

    I have no idea why the plugin install process wouldn’t create the em_ files, but I’m all set for now.

    Hi Jay,

    Paste this snippet in your theme’s functions.php and save the file. Then, in your Dashboard, refresh the page. If the table has been created, delete the snippet again from your functions.php.

    function recreate_events_table() {
    	global  $wpdb;
    	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    
    	$table_name = $wpdb->prefix.'em_events';
    	$query = "CREATE TABLE IF NOT EXISTS {$table_name} (
    		event_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    		post_id bigint(20) unsigned NOT NULL,
    		event_slug VARCHAR( 200 ) NULL DEFAULT NULL,
    		event_owner bigint(20) unsigned DEFAULT NULL,
    		event_status int(1) NULL DEFAULT NULL,
    		event_name text NULL DEFAULT NULL,
    		event_start_date date NULL DEFAULT NULL,
    		event_end_date date NULL DEFAULT NULL,
    		event_start_time time NULL DEFAULT NULL,
    		event_end_time time NULL DEFAULT NULL,
     		event_all_day int(1) NULL DEFAULT NULL,
    		event_start datetime NULL DEFAULT NULL,
    		event_end datetime NULL DEFAULT NULL,
    		event_timezone tinytext NULL DEFAULT NULL,
    		post_content longtext NULL DEFAULT NULL,
    		event_rsvp bool NOT NULL DEFAULT 0,
    		event_rsvp_date date NULL DEFAULT NULL,
    		event_rsvp_time time NULL DEFAULT NULL,
    		event_rsvp_spaces int(5) NULL DEFAULT NULL,
    		event_spaces int(5) NULL DEFAULT 0,
    		event_private bool NOT NULL DEFAULT 0,
    		location_id bigint(20) unsigned NULL DEFAULT NULL,
    		recurrence_id bigint(20) unsigned NULL DEFAULT NULL,
      		event_date_created datetime NULL DEFAULT NULL,
      		event_date_modified datetime NULL DEFAULT NULL,
    		recurrence bool NULL DEFAULT 0,
    		recurrence_interval int(4) NULL DEFAULT NULL,
    		recurrence_freq tinytext NULL DEFAULT NULL,
    		recurrence_byday tinytext NULL DEFAULT NULL,
    		recurrence_byweekno int(4) NULL DEFAULT NULL,
    		recurrence_days int(4) NULL DEFAULT NULL,
    		recurrence_rsvp_days int(3) NULL DEFAULT NULL,
    		blog_id bigint(20) unsigned NULL DEFAULT NULL,
    		group_id bigint(20) unsigned NULL DEFAULT NULL,
    		PRIMARY KEY  (event_id)
    		) DEFAULT CHARSET=utf8 ;";
    
    	$sql = $wpdb->query( $query );
    }
    add_action('admin_init', 'recreate_events_table');
    
    Jay Collier

    (@jcollier)

    Thanks! All set.

    Patrick Buntsma

    (@duisterdenhaag)

    Glad it worked. Happy to help! 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.