• Hi there, I’m working on my own plugin right now. It creates some custom pages that can be accessed in the admin panel. Which works after activating. Also the script I wrote should have to create a custom database table. The table won’t be created and I’m getting a weird error.

    The error is in dutch De plugin heeft 2350 fouten gegenereerd Onverwachte uitvoer tijdens activatie. Als je “headers al verzonden” berichten opmerkt, problemen met syndication feeds of andere problemen ervaart, probeer dan deze plugin te deactiveren of te verwijderen. But it’s not specially saying what’s wrong.

    I think there’s something wrong with the methods that create the db table:

    register_activation_hook(__FILE__, 'sportivity_api_active');
    function sportivity_api_activate(){
    	create_location_table();
    }
    
    function create_location_table(){
    	global $table_prefix, $wpdb;
    
        $table = 'locations';
        $wp_track_table = $table_prefix . $table;
    
        #Check to see if the table exists already, if not, then create it
    
        if($wpdb->get_var( "SHOW TABLES LIKE '$wp_track_table'" ) != $wp_track_table) 
        {
    		require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
    		
            $sql = "CREATE TABLE IF NOT EXISTS <code>&quot;. $wp_track_table . &quot;</code> ( ";
            $sql .= "  <code>id</code>  int(11)   NOT NULL auto_increment, ";
            $sql .= "  <code>title</code>  varchar(128)   NOT NULL, ";
            $sql .= "  <code>description</code>  varchar(200)   NOT NULL, ";
            $sql .= "  <code>sportivityApiKey</code>  varchar(175)   NOT NULL, ";
            $sql .= "  <code>insertDate</code>  bigint(8)   NOT NULL, ";
            $sql .= "  PRIMARY KEY <code>order_id</code> (<code>id</code>) "; 
            $sql .= ") ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; ";
            
            dbDelta($sql);
    		
    		var_dump($wpdb->suppress_errors);
    		wp_die();
    	}
    }

    I hope someone can help me figure this out.

    • This topic was modified 3 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 11 replies - 1 through 11 (of 11 total)
  • Wait, why are you creating a table like that?

    Thread Starter janmoes

    (@janmoes)

    I made my own custom plugin, and need to generate a table for api results.
    Is there an other way besides installing a plugin for it or so?

    No, I meant why are you creating a table in this way:

    $sql .= " <code>id</code> int(11) NOT NULL auto_increment, ";

    Thread Starter janmoes

    (@janmoes)

    Oh that <code> part somehow happened when posting this issue.
    Otherwise, if that’s not what you mean. I’m wondering how else you can generate a table.
    I would like to learn some more about it too! ??

    • This reply was modified 3 years, 5 months ago by janmoes.

    Ok, there are different approaches to do what you want to do. I don’t seem to follow why you have to create a new table instead of a new row?

    Thread Starter janmoes

    (@janmoes)

    It’s for an api, for the rest it has nothing to do with WP. So that’s probably why I did it that way.

    It’s for an api, for the rest it has nothing to do with WP. So that’s probably why I did it that way.

    I get that, but there are better ways to accomplish that. Even if it is for an API, if you are using WordPress, I suggest you to use existing tables instead.

    Thread Starter janmoes

    (@janmoes)

    What kind of table from wordpress standards would you prefer?

    What kind of table from wordpress standards would you prefer?

    I meant use cleaner code to create the tables.

    Thread Starter janmoes

    (@janmoes)

    Ah okay, cool!
    Do you have an example?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @janmoes I have removed your new topic. Please do not create duplicate topics, they are archived when found.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Error when activating my own plugin’ is closed to new replies.