Unable to Create Database Tables
-
Hi,
I am trying to make a plugin but am having some trouble, I cant see anything wrong with the below code but it doesnt seem to be working..
if(!defined('VURL_DBNAME')) define('VURL_DBNAME', 'vurls'); function vurl_plugin_options_install() { global $wpdb; $table_name = $wpdb->prefix . VURL_DBNAME; // create the ECPT metabox database table if($wpdb->get_var("show tables like '$table_name'") != $table_name){ $sql = "CREATE TABLE IF NOT EXISTS <code>$table_name</code> ( <code>id</code> int(11) NOT NULL AUTO_INCREMENT, <code>vurl</code> varchar(255) NOT NULL, <code>desturl</code> varchar(255) NOT NULL, <code>type</code> varchar(10) NOT NULL, PRIMARY KEY (<code>id</code>) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } register_activation_hook(__FILE__, 'vurl_plugin_options_install'); function vurl_pluginUninstall() { global $wpdb; $table_name = $wpdb->prefix . VURL_DBNAME; $wpdb->query("DROP TABLE IF EXISTS $table_name"); } register_uninstall_hook(__FILE__, 'vurl_pluginUninstall' );
Thanks for taking a look for me ??
Daniel
- The topic ‘Unable to Create Database Tables’ is closed to new replies.