jdbfitz Posted February 12, 2008 Share Posted February 12, 2008 The following code is NOT generating any errors .... but it is not creating the table either. Maybe I have been looking at this too long and can not see the obvious. Any thoughts? Thanks! $install_table_version = "1.0"; global $wpdb; global $install_table_version; $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); function install_table () { $my_ti=getdate(date("U")); $current_date=("$my_ti[year]-$my_ti[mon]-$my_ti[mday]"); $hours = $my_ti[hours]; $minutes = $my_ti[minutes]; $seconds = $my_ti[seconds]; $current_time=("$hours:$minutes:$seconds"); $table_name = $wpdb->prefix . "gluco"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, date1 time() DEFAULT '0' NOT NULL, time1 date() NOT NULL, level float(5,2) NOT NULL, fast VARCHAR(55) NOT NULL, comments VARCHAR(256) NOT NULL, num_display mediumint (9) NOT NULL, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); $date1 = $current_date; $time1 = $current_time; $level = "240"; $fast = "No"; $comments = "This is a test"; $num_display = "0"; $insert = "INSERT INTO " . $table_name . " (date1, time1, level, fast, comments, num_display) " . "VALUES ($wpdb->escape($date1), $wpdb->escape($time1), $wpdb->escape($level), $wpdb->escape($fast), $wpdb->escape($comments), $wpdb->escape($num_display))"; $results = $wpdb->query( $insert ); add_option("install_table_version", $install_table_version); } } Link to comment https://forums.phpfreaks.com/topic/90610-need-a-fresh-pair-of-eyes/ Share on other sites More sharing options...
toplay Posted February 12, 2008 Share Posted February 12, 2008 The $wpdb is not recognized inside the install_table() function. There's no () on date and time: date1 time() DEFAULT '0' NOT NULL, time1 date() NOT NULL, Link to comment https://forums.phpfreaks.com/topic/90610-need-a-fresh-pair-of-eyes/#findComment-464551 Share on other sites More sharing options...
jdbfitz Posted February 12, 2008 Author Share Posted February 12, 2008 Thanks ... I got it working Link to comment https://forums.phpfreaks.com/topic/90610-need-a-fresh-pair-of-eyes/#findComment-464577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.