SkyAuburn Posted May 18, 2019 Share Posted May 18, 2019 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'); Quote Link to comment https://forums.phpfreaks.com/topic/308724-db-table-create/ Share on other sites More sharing options...
SkyAuburn Posted May 18, 2019 Author Share Posted May 18, 2019 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? Quote Link to comment https://forums.phpfreaks.com/topic/308724-db-table-create/#findComment-1566845 Share on other sites More sharing options...
SkyAuburn Posted May 18, 2019 Author Share Posted May 18, 2019 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) );"; Quote Link to comment https://forums.phpfreaks.com/topic/308724-db-table-create/#findComment-1566846 Share on other sites More sharing options...
ginerjm Posted May 18, 2019 Share Posted May 18, 2019 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'. 1 Quote Link to comment https://forums.phpfreaks.com/topic/308724-db-table-create/#findComment-1566866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.