I am trying to redesign my previous code into a plugin but I have run into some issues. When I try to create a table using the below code. The table is not created. I tried to debug but I get no errors :S
Appreciate if you can have a look at the code. I also have another question. After I create the table I need to populate it via a csv file. Do you guys have any idea how to go around this as I have no idea where to start.
Thanks again
function upper_table(){
global $wpdb;
$table_name = $wpdb->prefix . "upper_winds";
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
$sql = "CREATE TABLE $table_name (
`LVL` VARCHAR(4) NOT NULL,
`REGION` TEXT NOT NULL,
`VALID` INT NOT NULL,
`CURRENT` TEXT NOT NULL
);";
//reference to upgrade.php file
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
} }
This code is in a functions php file and is called from the main plugin via
include ("functions_wx.php");
register_activation_hook(__FILE__,'upper_table');
The sql query above has been passed through PHPmyAdmin directly and has worked fined. Do not know if it could be a problem but I am currently running through WAMP server.