Hi there,
I'm trying to write a simple plugin for wordpress, I've followed instructions here: http://codex.wordpress.org/Creating_Tables_with_Plugins because I needed two new tables for my plugin.
Here's the sample code:
function wat_install ()
{
$table1 = $wpdb->prefix.'wat_ads';
$table2 = $wpdb->prefix.'wat_clicks';
if($wpdb->get_var("show tables like '$table1'") != $table1) {
$sql1="CREATE TABLE <code>$table1</code> (
<code>id</code> INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
<code>html</code> TEXT DEFAULT ' ',
PRIMARY KEY (<code>id</code>)
)
ENGINE = MyISAM;
";
}
if($wpdb->get_var("show tables like '$table2'") != $table2) {
$sql2="CREATE TABLE <code>$table2</code> (
<code>id</code> INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
<code>html</code> TEXT DEFAULT ' ',
PRIMARY KEY (<code>id</code>)
)
ENGINE = MyISAM;
";
}
$wpdb->query($sql1);
$wpdb->query($sql2);
}
register_activation_hook(__FILE__,'wat_install');
When I try to activate the plugin I get:
Plugin could not be activated because it triggered a fatal error.
Fatal error: Cannot redeclare wat_install() (previously declared in C:\*****\wp-content\plugins\wp-ad-tracking\wp-ad-tracking.php:14) in C:\*****\wp-content\plugins\wp-ad-tracking\wp-ad-tracking.php on line 39
Even though I get that error the plugin still shows up as activated on the plugin list, if I comment out "register_activation_hook(__FILE__,'wat_install');" no error will be produced, but I won't get my fancy tables.
Note: Line 14 is the first line inside the function that has some code while line 39 is the line here the end function bracket (}) is
I've tried several things and a lot of googling, but I'm lost, can anyone give me a hand?