Create table on activation problem
-
Hello to everyone,
I want my plugin to create a table when it is activated. Could anyone, please, tell me what I am doing wrong here?
MY CODE:
function TagRank_Activate()
{
$tags_ratings = $wpdb->prefix . “tags_ratings”;if ($wpdb->get_var(“SHOW tables LIKE ‘$tags_ratings'”) != $tags_ratings)
{
$sql = “CREATE table” . $tags_ratings . “(
id mediumint(9) NOT NULL AUTO_INCREMENT,
post_id mediumint(9) NOT NULL,
tag_id mediumint(9) NOT NULL,
rating bigint(11) DEFAULT ‘0’ NOT NULL,
UNIQUE KEY id (id)
);”;
require_once(ABSPATH . ‘wp-admin/upgrade-functions.php’);
dbDelta($sql);
}
}add_action(‘activate_tagrank.php’, ‘TagRank_Activate’);
My plugin is stored at wp-content/plugins/tagrank.php.
Thank you very much.
- The topic ‘Create table on activation problem’ is closed to new replies.