0

I am creating a few tables and I getting the following message:

The plugin generated 440 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 the code:

global $wpdb;

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

$table_name = $wpdb->prefix . jp_event_table;

$sql = "CREATE TABLE IF NOT EXISTS $table_name (
    id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    event_id BIGINT(20) UNSIGNED NOT NULL,
    name VARCHAR(50) NOT NULL,
    description TEXT,
    spaces INT,
    PRIMARY KEY  (ticket_id)
    ) ENGINE=InnoDB ;";

dbDelta($sql);

$sqlcomm = "CREATE TABLE IF NOT EXISTS WP_AWESOME_TABLES (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    PRIMARY KEY  (id)
    ) ENGINE=InnoDB ;";

dbDelta($sqlcomm);

I have searched around but I cannot find a solution to this. I am aware that using dbDelta() has a few weirdnesses to it (like having to have exactly two spaces after PRIMARY KEY), but did I miss anything?

More importantly: Is there some way for me to see what characters are being returned? Could it be an error message that would tell me what line of code is throwing the error? I have PHP debugging turned on but nothing is getting printed out.

Any suggestions would be extremely appreciated!

4
  • 1
    What is jp_event_table? A constant? Or a string and it should go in quotes? What else is done on activation? Is it only the above code, wrapped in a function, and that's it?
    – tfrommen
    Commented Apr 26, 2013 at 8:29
  • Yes sorry it's a constant from earlier in the code -
    – William
    Commented Apr 26, 2013 at 14:25
  • The first SQL snippet works? Because you are declaring ticket_id to be the PK, where no ticket_id column exists.
    – vancoder
    Commented Apr 26, 2013 at 16:22
  • If you add a die() after your code snippet, you should see the error message.
    – vancoder
    Commented Apr 26, 2013 at 16:36

1 Answer 1

0
function jal_install() {

   global $jal_db_version;

   $sql = "CREATE TABLE IF NOT EXISTS WP_AWESOME_TABLES (
           id mediumint(9) NOT NULL AUTO_INCREMENT,
           PRIMARY KEY id (id)
           );";

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

   dbDelta( $sql );

   add_option( "jal_db_version", $jal_db_version ); 

}

register_activation_hook( _____FILE_____, 'jal_install' );

You have to hook the function. After activate the plugin table will created.

http://codex.wordpress.org/Creating_Tables_with_Plugins

2
  • Yes I know - I have hooked the install function elsewhere - when I comment out the second CREATE TABLE statement, it works fine and it just says 'Plugin Activated' (I checked in phpMyAdmin to ensure that the first table was successfully created). But when both statements are there, I get the message that I put above -
    – William
    Commented Apr 26, 2013 at 14:35
  • is the datatype case sensitive? I.e. is mediumint(9) work the same as MEDIUMINT(9)?
    – William
    Commented Apr 26, 2013 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.