User
User

Reputation: 1488

Wordpress table not being created

I have been trying to create a new table for my wordpress plugin for a few hours now without success.

My best guess is that there is some error in the sql which i cannot find. I have been trying to look at the wordpress codex and other sources as well without success. Would apprechiate some help!

 register_activation_hook( __FILE__, 'plugin_install' );


function plugin_install(){
   require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   global $wpdb;

   $table_name = $wpdb->prefix . 'dbname';
   $charset_collate = $wpdb->get_charset_collate();

   $sql_create_table = "CREATE TABLE $table_name (
           id mediumint(9) NOT NULL PRIMARY KEY AUTO_INCREMENT,
           b_id int(11) NOT NULL,
           iprefix varchar(20) NOT NULL default '0',
           istart bigint(20) NOT NULL default 'updated',
           iend bigint(20) unsigned NOT NULL default '0',
           isuffix varchar(20) NOT NULL default 'post',
           PRIMARY KEY  (id)
      ) $charset_collate; ";

      dbDelta( $sql_create_table );
   }

Upvotes: 0

Views: 57

Answers (1)

Victor Font
Victor Font

Reputation: 37

In the fourth line of your create SQL code you have an unsigned varchar. Remove the unsigned keyword and it should be fine.

Upvotes: 1

Related Questions