$wpdb | installing custom table plugin
-
Please help, I’m desperate (new at plugins and I’m struggling) Creating a simple plugin for a uni assignment which is due in a few days –
Plugin not working 8o( – just simply want to install a custom database using $wpdb – currently have 2 files to just configure the custom table (I am very new to plugins so it’s going to be a really silly error). Once this is installed, I can use a custom form so that users can submit details to the custom table (next stage)
Nothing happens when the plugin is activated – it activates with no errors but the DB does not configure in phpmyadmin >>
File 1 – traderegistrationform.php
File 2 – utddb_install.phpFILE 1: TRADEREGISTRATIONFORM.PHP
<?php/*
Plugin Name: Trade Registration Form
*/
register_activation_hook(utddb_install.php,’utddb_install’);
register_activation_hook(utddb_install.php,’utddb_install’);?>
FILE 2: UTDDB_INSTALL.PHP
<?php
/*
*/
global $utddb_version;
$utddb_version = “1.0”;function utddb_install () {
global $wpdb;
global $utddb_version;$tablename = $wpdb->prefix . “user_trade_details”;
$sql = “CREATE TABLE ‘$tablename’ (
‘company_id’ bigint(20) NOT NULL AUTO_INCREMENT,
‘user_id’, bigin(20)
‘firstname’ varchar(60) NOT NULL,
‘lastname’ varchar(60) NOT NULL,
‘contactno’ bigint(15) NOT NULL,
‘company_name’ varchar(100) NOT NULL,
‘customer_type’ char(1) NOT NULL,
‘address_1’ text,
‘address_2’ text,
‘town’ text,
‘county’ text,
‘post_code’ text,
‘registration_date’ datetime,
‘company_no’ bigin(20)
);”;require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
dbDelta($sql);add_option(“utddb_version”, $utddb_version);
}?>
ANY IDEAS 8O(
The topic ‘$wpdb | installing custom table plugin’ is closed to new replies.