jract7
Member
Posted 8 months ago #
I'm attempting to create a table via a plugin... everything seems to be good, but I'm not getting the table created...
Any ideas of what I'm doing wrong?
[Code moderated as per the Forum Rules. Please use the pastebin]
And calling it with the hook:
register_activation_hook(__FILE__,'jsadb_install');
jract7
Member
Posted 8 months ago #
function jsadb_install()
{
global $wpdb;
$table = $wpdb->prefix.'jsadb';
if($wpdb->get_var("show tables like '$table'") != $table_name)
{
$sql = "CREATE TABLE".$table."
(
id INT(9) NOT NULL AUTO_INCREMENT,
postdate VARCHAR(10) NOT NULL,
name VARCHAR(50) NOT NULL,
posttitle VARCHAR(64) NOT NULL,
UNIQUE KEY id (id)
);
";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
}
register_activation_hook( __FILE__, 'jsadb_install' );