“The plugin generated 2694 characters of unexpected output…” on Plugin activation, CREATE TABLE sql command not working


Trying to create a table in the wpdb when activating the plugin I am working on and getting the error “The plugin generated 2694 characters of unexpected output…”

I’ve been over the code and done heaps of googling to try and figure out what I’ve done wrong with no success.
Can someone take a look and see if there is something obvious I’m not seeing? Much appreciated.

Note: The plugin still activates and creates the menu just fine, but it will not create the table in the database.


// plugin details in comment at top

defined('ABSPATH') or die('You should not be here…');

function tmadm_activation() {
register_activation_hook( __FILE__, 'tmadm_activation' );

function tmadm_deactivation() {
register_deactivation_hook( __FILE__, 'tmadm_deactivation' );

// Insert "Students" Table to WP Database

global $tmadm_db_version;
$tmadm_db_version = '0.1.0';

function tmadm_install() {
    global $wpdb;
    global $jal_db_version;

    $table_name = $wpdb->prefix . 'tmadm_students';

    $charset_collate = $wpdb->get_charset_collate();

    $sql = "CREATE TABLE $table_name (
        studentnumber text NOT NULL,
        dojang text NOT NULL,
        firstname tinytext NOT NULL,
        lastname tinytext NOT NULL,
        title text NOT NULL,
        gender text NOT NULL,
        bbtitle text,
        titleid text,
        instructorcertexpire datetime DEFAULT '0000-00-00 00:00:00',
        wwcnumber text,
        wwcexpire date DEFAULT '0000-00-00',
        firstaidnumber text,
        firstaidrto text,
        firstaidexpire date DEFAULT '0000-00-00',
        cprexpire date DEFAULT '0000-00-00',
        streetaddress NOT NULL,
        suburbaddress NOT NULL,
        postcodeaddress NOT NULL,
        phhome text,
        phwork text,
        phmobile text,
        email text NOT NULL,
        dateofbirth date NOT NULL,
        height text NOT NULL,
        weight text NOT NULL,
        lastupdated date NOT NULL,
        beltsize text NOT NULL,
        uniformsize text NOT NULL,
        occupation text NOT NULL,
        nationality text,
        emergencycontact text NOT NULL,
        relationship text NOT NULL,
        phhomeemergency text NOT NULL,
        phworkemergency text NOT NULL,
        phmobileemergency text NOT NULL,
        reference text,
        referenceinternet text,
        applicationdate date DEFAULT '0000-00-00' NOT NULL,
        currentrank text NOT NULL,
        rankid text NOT NULL,
        ranktitle text NOT NULL,
        consentpart1 text NOT NULL,
        consentpart2 text NOT NULL,
        consentpart3 text NOT NULL,
        consentpart4 text NOT NULL,
        consentpart5 text NOT NULL,
        consentpart6 text NOT NULL,
        consentpart7 text NOT NULL,
        consentpart8 text NOT NULL,
        consentpart9 text NOT NULL,
        consentpart10 text NOT NULL,
        consentpart11 text NOT NULL,
        consentpart12 text NOT NULL,
        completeconsent text NOT NULL,
        Consentby text NOT NULL,
        active text NOT NULL,
        agreedfee text,
        autobilled text,
        billfrequency text,
        newfee text,
        PRIMARY KEY  (id)
    ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );

    add_option( 'tmadm_db_version', $tmadm_db_version );

// Insert initial data into Students Table
function tmadm_install_data() {
    global $wpdb;

    $table_name = $wpdb->prefix . 'tmadm_students';

            'studentnumber' => '00XX1',
    //rest of this data removed as it contains personal data
register_activation_hook(__FILE__, 'tmadm_install');
register_activation_hook(__FILE__, 'tmadm_install_data');

// Plugin Settings Menu
add_action( 'admin_menu', 'tmadm_admin_menu' );

function tmadm_admin_menu() {
    add_menu_page( 'TMA Dojang Manager', 'Dojang Manager', 'manage_options', 'tmadm_settings', 'tmadm_settings_page', '', 50  );
    add_submenu_page( 'tmadm_settings', 'General Settings', 'General Settings', 'manage_options', 'tmadm_settings', 'tmadm_settings_page' );
    add_submenu_page( 'tmadm_settings', 'Dojang Settings', 'Dojang Management', 'manage_options', 'tmadm_settings', 'tmadm_settings_page' );
    add_submenu_page( 'tmadm_settings', 'Instructor Settings', 'Instructor Management', 'manage_options', 'tmadm_settings', 'tmadm_settings_page' );
    add_submenu_page( 'tmadm_settings', 'Student Settings', 'Student Management', 'manage_options', 'tmadm_settings', 'tmadm_settings_page' );

function tmadm_settings_page(){
    include 'admin/tmadm-admin-page.php';

, , Daniel Florian 3 years 2020-03-27T20:51:07-05:00 0 Answers 123 views 0

Leave an answer