I am attempting to create my own plugin, and am running into a fatal error when I attempt to activate it. I cannot figure out why. As of now, the only thing the plugin does is create a new DB table at activation. Here is the code
$rbVersion = "1.0";
//install DB tables
function rb_install() {
global $wpdb;
//first check to see if the DB table already exists
$tableName = $wpdb->prefix . "rusty_beard";
if($wpdb->getvar("SHOW TABLES LIKE '" . $tableName . "'") != $tableName) {
//create DB tables
$install = "CREATE TABLE " . $tableName . "(
field_id KEY INT NOT NULL AUTO_INCREMENT,
field_name VARCHAR(50),
field_type VARCHAR(50),
field_default VARCHAR(240),
field_required INT,
field_label VARCHAR(240)
field_order INT)";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($install);
//add version to DB
add_option("rb_version", $rbVersion);
}
}
//install the plugin
register_activation_hook(__FILE__, 'rb_install');
This is all located in the main plugin file, the only plugin file I have.
When I attempt to activate it, WP gives the following error:
Plugin could not be activated because it triggered a fatal error.
Fatal error: Cannot redeclare rb_install() (previously declared in /home/dir/public_html/dir/wp-content/plugins/RustyBeard/rusty_beard.php:21) in /home/dir/public_html/dir/wp-content/plugins/RustyBeard/rusty_beard.php on line 45