• Resolved cjpicc11

    (@cjpicc11)


    I am developing a plugin that I would like to have a table created when it is activated. When I activate the plugin, I am seeing that the table is being created successfully, however, I am getting the following message.

    The plugin generated 20 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.

    Here is my code, any help is appreciated…

        <?php 
        function pfw_activate_plugin(){
            if(version_compare(get_bloginfo('version'), '4.8', '<')){
                wp_die(__('You must update wordpress to use this plugin','pfw-members'));
            }
    
            global $wpdb;
            
            
                
                $createSQL =  "
                CREATE TABLE <code>&quot; . $wpdb->prefix. &quot;pfw_person</code> (
                <code>id</code> INT(11) NOT NULL AUTO_INCREMENT,
                <code>update_date</code> TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                <code>first_name</code> VARCHAR(50) NOT NULL COLLATE utf8_bin,
                <code>last_name</code> VARCHAR(75) NOT NULL COLLATE utf8_bin,
                <code>user_id</code> INT(11) NOT NULL,
                <code>person_type</code> VARCHAR(50) NOT NULL COLLATE utf8_bin,
                <code>create_date</code> DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
                PRIMARY KEY (<code>id</code>)
                ) ENGINE=InnoDB " . $wpdb->get_charset_collate() . " AUTO_INCREMENT=1;";
               
                
                require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
                dbDelta($createSQL);       
            
    
        }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Do you have any spaces before the initial <?php? Also, remove the closing ?> on the php file as there may also be spaces after it.

    Thread Starter cjpicc11

    (@cjpicc11)

    Thank you. This didn’t directly resolve my issue, but I had several other plugin php files that had spaces at the opening and closing of the php declaration.

    Appreciate your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting Unexpected Errors when Activating a wordpress Plugin’ is closed to new replies.