Error in creating table in db for my plugin
-
I am trying to create a table for my plugin. But when I activate the plugin, the table is not creating.
Attaching the code.
function skoop_table () { global $wpdb; $table_name = $wpdb->prefix .'skoop_category'; $charset_collate = $wpdb->get_charset_collate(); if($wpdb->get_var("SHOW TABLES LIKE '$table_name'" ) != $table_name){ $sql= "CREATE TABLE $table_name ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, categoey VARCHAR(30) NOT NULL, time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, );"; require_once (ABSPATH. 'wp-admin/includes/upgrade.php' ); dbDelta($sql); } } register_activation_hook( __FILE__, 'skoop_table' ); function add_skoop_data() { global $wpdb; $categoey = ''; $table_name = $wpdb->prefix .'skoop_category'; $wpdb->insert( $table_name, array( 'time' => current_time( 'mysql' ), 'category' => '', ) ); } register_activation_hook( __FILE__, 'add_skoop_data' );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Error in creating table in db for my plugin’ is closed to new replies.