Jump to content

DB Table create


SkyAuburn

Recommended Posts

For the life of me I can not figure out why this is not creating the table in the database.  Second set of eyes would be great.

 

function install_kudos() {
 	
 	    global $wpdb;
        $table_name = $wpdb->prefix . 'acikudosnew';
 
        if ($wpdb->get_var('SHOW TABLES LIKE ' .$table_name) != $table_name) 
        {
	    $sql = "CREATE TABLE $table_name (
		kudoid int(9) NOT NULL AUTO_INCREMENT,
        kudomsg text NOT NULL,
        kudoagent text NON NULL,
        kudocust text NOT NULL,
        kudoacct int(16) NOT NULL,
        kudoclient varchar(100) NOT NULL,
        kudoloc text NOT NULL,
        kudoentry TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        kudoadmin text NOT NULL,
		kudopic varchar(55) DEFAULT '' NOT NULL,
		PRIMARY KEY  (kudoid) )";
	       
	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
	dbDelta( $sql );
	}
 	
 }
  
register_activation_hook(__FILE__, 'install_kudos');

 

 

Link to comment
Share on other sites

Not sure what happened, rewrote the sql from scratch and I think it hates me because it now works with this code.  Still have no idea what is going on as it looks the same as orig other than the  mediumint
 

	$sql = "CREATE TABLE $table_name (
		kudoid mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
		kudomsg text NOT NULL,
        kudoagent text NOT NULL,
        kudocust text NOT NULL,
        kudoacct int(16) NOT NULL,
        kudoclient varchar(100) NOT NULL,
        kudoloc text NOT NULL,
        kudoentry TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        kudoadmin text NOT NULL,
		kudopic varchar(55) DEFAULT '' NOT NULL,
		PRIMARY KEY  (kudoid)
		);";

 

Link to comment
Share on other sites

If you had php error checking turned on (as one should during ALL DEVELOPMENT) you would have probably been told of an error.  In your first attempt you had a 'NON null' phrase on one field  when you probably meant to use 'NOT null'.

  • Thanks 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.