<?php
/*
Plugin Name: SQL table creator
Author: Md. Sarwar-A-Kawsar
Author URI: https://xyz.abc
*/
defined('ABSPATH') or die('You cannot access to this page');
function stb_sql_custom_activate(){
global $wpdb;
$table_name = $wpdb->prefix.'eg_all_videos';
if( $wpdb->get_var("SHOW TABLES LIKE ".$table_name) != $table_name ){
$sql = "CREATE TABLE $table_name (
id INT(5) NOT NULL AUTO_INCREMENT,
old_id INT(5) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
title VARCHAR(300) DEFAULT NULL,
year year(4) DEFAULT NULL,
segment_number INT(3) DEFAULT NULL,
slug VARCHAR(300) DEFAULT NULL,
UNIQUE KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
}
register_activation_hook( __FILE__, 'stb_sql_custom_activate' );
I've used the above code in my plugin but getting this error during activate the plugin:
The plugin generated 515 characters of unexpected output during activation. If you notice “headers
already sent” messages, problems with syndication feeds or other issues, try deactivating or removing
this plugin.
I've changed the SQL query but didn't get any luck and would appreciate if anyone helps to solve this issue.
Regards