title: create a table in wordpress database within function.php
body: <p>im trying to create a custom table into my wordpress database inorder to save episodes rates, i wanna use function PHP since i dont wanna create a plugin
  i hv used this code but it dont work, the table wont be created, any helps.</p>
  
  <pre><code>function ratings_fansub_create() {
  
      global $wpdb;
      $table_name = $wpdb-&gt;prefix. "ratings_fansub";
      global $charset_collate;
      $charset_collate = $wpdb-&gt;get_charset_collate();
      global $db_version;
  
      if( $wpdb-&gt;get_var("SHOW TABLE LIKE " . $table_name)!= $table_name)
      {   $create_sql = "CREATE TABLE ".$table_name. "(
              ratings_fansub_id INT(11) NOT NULL auto_increment,
              ratings_fansub_postid INT(11) NOT NULL ,
              ratings_fansub_posttitle TEXT NOT NULL,
              ratings_fansub_rating INT(2) NOT NULL ,
              ratings_fansub_timestamp VARCHAR(15) NOT NULL ,
              ratings_fansub_ip VARCHAR(40) NOT NULL ,
              ratings_fansub_host VARCHAR(200) NOT NULL,
              ratings_fansub_username VARCHAR(50) NOT NULL,
              ratings_fansub_userid int(10) NOT NULL default '0',
              ratings_fansub_PRIMARY KEY (id))$charset_collate;";
      }
                  require_once(ABSPATH . "wp-admin/includes/upgrade.php");
      dbDelta( $create_sql );
  
  
  
  
      //register the new table with the wpdb object
      if (!isset($wpdb-&gt;ratings_fansub)) 
      {
          $wpdb-&gt;ratings_fansub = $table_name; 
          //add the shortcut so you can use $wpdb-&gt;stats
          $wpdb-&gt;tables[] = str_replace($wpdb-&gt;prefix, '', $table_name); 
      }
  
  }
  add_action( 'init', 'ratings_fansub_create');
  </code></pre>