// Initialization and Hooks
global $wpdb;
global $wp_version;
global $wpmyfirstplugin_version;
global $wpmyfirstplugin_db_version;
global $wpmyfirstplugin_table_name;
global $wp_version;
$wpmyfirstplugin_version = '1.0.1';
$wpmyfirstplugin_db_version = '0.0.1';
$wpmyfirstplugin_table_name = $wpdb->prefix.'imart_setting';
function wpmyfirstplugin_install()
{
global $wpdb;
global $wpmyfirstplugin_table_name;
global $wpmyfirstplugin_db_version;
// create table on first install
if($wpdb->get_var("show tables like '$wpmyfirstplugin_table_name'") != $wpmyfirstplugin_table_name) {
wpmyfirstplugin_createTable($wpdb, $wpmyfirstplugin_table_name);
//add_option("wpmyfirstplugin_db_version", $wpmyfirstplugin_db_version);
//add_option("wpmyfirstplugin_configuration", '');
}
}
function wpmyfirstplugin_createTable($wpdb, $table_name)
{
$sql = "CREATE TABLE ".$table_name." (
main_id bigint(20) NOT NULL auto_increment,
main_key varchar(255) default NULL,
main_value longtext,
PRIMARY KEY (`imart_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
$results = $wpdb->query($sql);
}
register_activation_hook(__FILE__,'wpmyfirstplugin_createTable');
Above is what I key in for starter. When I activate I get the following:
Warning: Missing argument 2 for wpmyfirstplugin_createTable()
This one point to the execution of wpmyfirstplugin_createTable
at
wpmyfirstplugin_createTable($wpdb, $wpmyfirstplugin_table_name);
Fatal error: Call to a member function query() on a non-object
This one point to the line where I run
$results = $wpdb->query($sql);
What did I do wrong actually?