Quantcast
Channel: activation – WordPress.org Forums
Viewing all articles
Browse latest Browse all 914

codyt on "Creating a plugin - Why is my table not being created upon activation?"

$
0
0

So I'm trying to build a plugin that allows a Wordpress member to create multiple role playing characters.

I'm not getting any error messages. It simply doesn't install a the table I've commanded it to. I've checked my my WPDB in PHPMyAdmin for the table "myth_char", but didn't find it. Maybe it's just something to do with the spacing. The codex seems to be pretty picky about that.

<?php
/**
* Plugin Name: Myth Create
* Plugin URI: http://wordpress.com/
* Description: Create and manage characters.
* Version: 1.0
* Author: Cody Tetreault
* Author URI: http://www.Mythlarp.com
* License: #ML

{myth_create} is not intended to be to be used by any other party than the original creator. This plugin is designed only for our website, http://mythlarp.com.
*/

//register all hooks
register_activation_hook( __FILE__, 'myth_install' );

//INSTALL

  function myth_install(){
     global $wpdb;
     global $myth_db_version;

  $table_name = $wpdb->prefix . "myth_char";

  $charset_collate = $wpdb->get_charset_collate();

  $sql = "CREATE TABLE $myth_char (
      id int(10) NOT NULL AUTO_INCREMENT,
      char_id int(10) NOT NULL AUTO_INCREMENT,
      char_name varchar(20) DEFAULT 'MAJABA' NOT NULL,
      time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
      PRIMARY KEY myth_char_pk char_id,
      FOREIGN KEY myth_char_fk (id) REFERENCES wp_users(id)
  );";

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

add_option( "myth_db_version", $myth_db_version );

}

?>

Viewing all articles
Browse latest Browse all 914

Trending Articles