Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter sturdyindian

    (@sturdyindian)

    Hi,
    It is working now.
    Updated Code below.

    <?
    /*
    Plugin Name: My Plugin 8
    Plugin URI: https://www.example.com/myplugin
    Description: This is a really great plugin that extends WordPress.
    Version: 1.0.0
    Author: Pradeep
    */
    function fun_install_tables () {
    global $wpdb;
    $charset_collate = ”;
    if ( version_compare(mysql_get_server_info(), ‘4.1.0’, ‘>=’) ) {
    if (!empty($wpdb->charset)) {
    $charset_collate .= ” DEFAULT CHARACTER SET $wpdb->charset”;
    }
    if (!empty($wpdb->collate)) {
    $charset_collate .= ” COLLATE $wpdb->collate”;
    }
    }
    $table=$wpdb->prefix.”test”;
    $sql=”CREATE TABLE IF NOT EXISTS $table (
    id int(11) NOT NULL auto_increment,
    name varchar(50) collate utf8_unicode_ci NOT NULL,
    PRIMARY KEY (id)
    )$charset_collate;”;
    require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
    dbDelta($sql);
    $sql = “insert into $table (name)values(‘apj kalam’)”;
    $wpdb->query($sql);

    }
    register_activation_hook(__FILE__,’fun_install_tables’);
    ?>

    Thanks…

Viewing 1 replies (of 1 total)