I don't know where the mistake is. My code is not creating a table in WAMP:

function subscribe_table() {
    global $wpdb;

    $table_name = $wpdb->prefix.'_databasesubs';

    $charset_collate = $wpdb->get_charset_collate();
    if ( $wpdb->get_var( 'SHOW TABLES LIKE '. $table_name ) != $table_name ) {  
        $sql = "CREATE TABLE $table_name (
                sno int(2) NOT NULL AUTO_INCREMENT, email varchar(25), name varchar(25), contact int(10)
            ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );
register_activation_hook( __FILE__, 'subscribe_table' );

Try edit Privileges for your wordpress database user from phpMyAdmin.

enter image description here



I reviewed your comment and there is no issue in code but check following details.

Please deactive and again active your plugin. If you still encounter issue then follow the further steps from: http://premium.wpmudev.org/blog/creating-database-tables-for-plugins/

PS: If this stuff helps you please leave me a comment and support :)



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.