Hi everyone.
I'm trying to create (my first real) plugin, but seem to be stuck at the step where I create my tables. Could someone provide any insight to what I'm doing wrong?
$st_db_version = "0.1";
function st_install(){
global $wpdb;
global $st_db_version;
$table_name = $wpdb->prefix . "spinthat";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
st_id mediumint(9) NOT NULL AUTO_INCREMENT,
st_time bigint(11) DEFAULT '0' NOT NULL,
st_artist tinytext NOT NULL,
st_album tinytext NOT NULL,
st_rating mediumint(6) DEFAULT '0' NOT NULL,
st_blurb text NOT NULL,
st_img VARCHAR(100) NOT NULL,
st_url VARCHAR(100) NOT NULL,
PRIMARY KEY (st_id)
);";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);
add_option("st_db_version", $st_db_version);
}
}
add_action('activate_plugindir/wp_spinthat.php', 'st_install');
Thanks a lot,
Jack