Jump to content
SkyAuburn

DB Table create

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');

 

 

Share this post


Link to post
Share on other sites

Doing some tests with the insert. If I remove the NOT NULL from everything after kudomsg it goes in.  Anybody have an idea of why it dies when NOT NULL is in the SQL?

Share this post


Link to post
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)
		);";

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.