Issue with WordPress Plugin Activation Hook and Table Creation

Not sure if this helps but try doing this in the main plugin file: require plugin_dir_path(__FILE__).’inc/plugin-setting.php’; require plugin_dir_path(__FILE__).’inc/db.php’; // Register activation hook in the main plugin file register_activation_hook(__FILE__, ‘wp_comment_reactions’); Move your function wp_comment_reactions to the db.php file and call it from the main plugin file.

What is wrong with this dbDelta syntax?

The dbDelta function is super nitpicky. Everything has to be exactly correct. In this case, the lack of space between the table name and the parentheses following it will cause your call to fail, because it can’t figure out the table name without that space. The relevant code in dbDelta() is this: if (preg_match(“|CREATE TABLE … Read more

Print output of Table Creation

function jal_install() { global $jal_db_version; $sql = “CREATE TABLE IF NOT EXISTS WP_AWESOME_TABLES ( id mediumint(9) NOT NULL AUTO_INCREMENT, PRIMARY KEY id (id) );”; require_once( ABSPATH . ‘wp-admin/includes/upgrade.php’ ); dbDelta( $sql ); add_option( “jal_db_version”, $jal_db_version ); } register_activation_hook( _____FILE_____, ‘jal_install’ ); You have to hook the function. After activate the plugin table will created. http://codex.wordpress.org/Creating_Tables_with_Plugins

Creates only one table and not the other

dbdelta demands that: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition of your primary key. You must use the key word KEY rather than its synonym INDEX and you must include at least one KEY. You must … Read more

Creating a database in my plugin not working

You have syntax error. You don’t need single quote for column name. You can use phpmyadmin to test MySQL queries. $sql = “CREATE TABLE IF NOT EXISTS $table_name ( id INT(6) NOT NULL AUTO_INCREMENT , user_id TEXT NOT NULL, full_name TEXT NOT NULL, email TEXT NOT NULL, invoiceNumber TEXT NOT NULL, plan_type TEXT NOT NULL, … Read more

dbDelta not CREATING TABLE

You are missing comma end of phone varchar(10) NOT NULL line, add comma end of line after that table will be created. I have tested https://prnt.sc/qgqmog function lapizzeria_database() { global $wpdb; global $lapizzeria_db_version; $lapizzeria_db_version = “1.0”; $table = $wpdb->prefix . ‘reservation’; $charset_collate = $wpdb->get_charset_collate(); //SQL Statement $sql = “CREATE TABLE $table ( id mediumint(9) NOT … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)