php - Create database tables when wordpress plugin is activated -


i have develop plugin need table on database , function create table on activation:

defined( 'abspath' ) or exit; global $mva_db_version; $mva_db_version = '1.0';  function setup_on_activation(){     if ( ! current_user_can( 'activate_plugins' ) )         return;     $plugin = isset( $_request['plugin'] ) ? $_request['plugin'] : '';     check_admin_referer( "activate-plugin_{$plugin}" );      global $wpdb;     $db_name = $wpdb->prefix . 'table_test';     $charset_collate = $wpdb->get_charset_collate();      $sql = "create table if not exist $db_name (       id int(11) not null auto_increment,       title text not null,       content text not null,       shortcode text not null,       primary key (id)     ) $charset_collate;";      require_once( abspath . 'wp-admin/includes/upgrade.php' );     dbdelta( $sql );     add_option( 'mva_db_version', $mva_db_version ); } register_activation_hook(__file__,'setup_on_activation'); 

i have followed same example here, doesnt create me table on database, there probleme code?

i add following picture show error displayed when activating plugin: error activationg plugin


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -