Title: Plugin not creating table on activation
Last modified: August 22, 2016

---

# Plugin not creating table on activation

 *  [Torkaaa](https://wordpress.org/support/users/torkaaa/)
 * (@torkaaa)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/plugin-not-creating-table-on-activation-1/)
 * My plugin doesn’t create table on activation SQL code is right and other parts
   of code seems right too. Why It doesn’t work ?
 *     ```
       class MySimpleForm
       {		
   
       	public function __construct()
       	{
       		/*** Includes ***/
       		include_once plugin_dir_path(__FILE__).'/db.php';
       		/*** Instanciation ***/		
   
       		register_activation_hook(__FILE__, array('MySimpleForm','install'));
       	}
   
       	public static function install()
       	{
       		MSF_db::createTable();
       	}
       }
   
       new MySimpleForm();
       ```
   
 * db.php file
 *     ```
       class MSF_db
       {
       	public function __construct()
       	{
   
       	}
   
       	public static function createTable()
       	{
       		global $wpdb;
       		$wpdb->query('CREATE TABLE IF NOT EXISTS {$wpdb->prefix}msf_form_data
       			     (id INT PRIMARY KEY,
       			     firstname VARCHAR(50) NOT NULL,
       			     lastname VARCHAR(50) NOT NULL,
       			     email VARCHAR(200) NOT NULL);');
       	}
   
       	public static function dropTable()
       	{
   
       	}
       }
       ```
   

The topic ‘Plugin not creating table on activation’ is closed to new replies.

## Tags

 * [Creation](https://wordpress.org/support/topic-tag/creation/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * 0 replies
 * 1 participant
 * Last reply from: [Torkaaa](https://wordpress.org/support/users/torkaaa/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/plugin-not-creating-table-on-activation-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
