Problem in creating table through plugin code

The above code should be placed in a function and then hook that with plugin activation hook? Here’s sample structure of plugin-name.php file. Note – Use CREATE TABLE IF NOT EXISTS instead only create table Code Updated on – 2012-08-04 <?php // this code goes into your my_plugin_name.php file function install_my_plugin() { global $wpdb; $table_name … Read more

What files to keep after upgrading WordPress?

Delete everything but wp-content and wp-config.php, copy the fresh installation into the directory. On upgrading WordPress will use the database to see what should be done, not the files. Not all files are deleted automatically, because some of them might still be used by outdated plugins or external scripts (the old feed files are good … Read more

Custom database table for plugin not creating on activation

Here’s an updated version of pf_rb_install(). In the table creation SQL, $table_name should not be in quotes. The quotes should have triggered an error which would appear in PHP’s error.log file. Also, there should be two spaces after the PRIMARY KEY (id) portion of the SQL statement. register_activation_hook( __FILE__, ‘pf_rb_install’ ); function pf_rb_install() { global … Read more

Why does dbDelta() not catch MysqlErrors?

As @Charleston Software Associates mentioned, the DESCRIBE query should not be executed if the table doesn’t exist. The best solution, as he pointed out, is to prevent the error from occurring in the first place. To do so, patch wp-admin/includes/upgrade.php as follows: Change the following line from dbDelta(): $tablefields = $wpdb->get_results(“DESCRIBE {$table};”); to: //Begin core … Read more

dbDelta ALTER TABLE syntax?

You’ve used the dbDelta function incorrectly. The whole point of that function is you pass in a table creation SQL command. If the table doesn’t exist, it creates it. If the table exists but doesn’t match, it’s modified until it matches. This includes adding and updating columns, indexes, and other aspects. So what you want … Read more

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