create tables (ok and not ok at same time)
-
Hi,
I put the following code inside my activation hook function:
function easydm_create_table_in_wpdb(){ global $wpdb; $table_name = $wpdb->prefix.'easy_downloader_manager'; $charset_collate = $wpdb->get_charset_collate(); echo '<script type="text/javascript">alert('.$charset_collate.');</script>'; $sql = "CREATE TABLE $table_name ( name varchar(20) NOT NULL, level int(1) NOT NULL, url varchar(55) DEFAULT '' NOT NULL ) $charset_collate;"; require_once( ABSPATH.'wp-admin/includes/upgrade.php' ); dbDelta( $sql, true ); }
and
function easydm_activation() { $path = WP_CONTENT_DIR.'/easydm-uploads'; if( !file_exists( $path ) ){ mkdir( $path ); } easydm_create_table_in_wpdb(); }
When the plugin is activated, it creates a directory and a table in wp db. I’m in ubuntu 14.04 and keep my file manager opened to see the directory appear (no problem here). It’s weird, when I insert the function to create the table, because I keep phpMyAdmin opened to see the table creation (and it is created in all activation) even the following message appears to me:
The plugin generated 104 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
what should I do? How to debugger correctly? I wanna publish my plugins (this first and future ones) in WordPress repository
- The topic ‘create tables (ok and not ok at same time)’ is closed to new replies.