Title: My php code is not creating a table
Last modified: August 19, 2016

---

# My php code is not creating a table

 *  [kathymac](https://wordpress.org/support/users/kathymac/)
 * (@kathymac)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/my-php-code-is-not-creating-a-table/)
 * Hello,
 * I have created a plugin called “CreateCustomTable”.
    In this directory I have
   2 files: “CreateCustomTable” and “create.php”. The “CreateCustomTable” php file
   has a button that is forwarded to “create.php” which is suppose to create a custom
   table called “wp_prod_info”. However this is not working. Could someone let me
   know what I’ve done wrong?
 * create.php code below……
 * <?php
 *  $table_name = “wp_product_info”;
 *  $sql = “CREATE TABLE ” . $table_name . ” ( “;
    $sql .= “prod_id mediumint(9)
   NOT NULL AUTO_INCREMENT, “; $sql .= “prod_name VARCHAR(100) NOT NULL, “; $sql.
   = “prod_details VARCHAR(255) NOT NULL, “; $sql .= “prod_reg_price DECIMAL(4,2)
   NOT NULL DEFAULT ‘0.00’, “; $sql .= “prod_sale_price DECIMAL(4,2) NOT NULL DEFAULT‘
   0.00’, “; $sql .= “prod_image_url VARCHAR(255) “; $sql .= ” ); “;
 *  print (“$sql
   “);
 *  $sPath = “[http://www.eastcoasttechwriter.ca/wp-admin/includes/upgrade.php&#8221](http://www.eastcoasttechwriter.ca/wp-admin/includes/upgrade.php&#8221);;
 *  require_once($sPath );
 *  dbDelta($sql);
 * ?>

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/my-php-code-is-not-creating-a-table/#post-1752344)
 * Not sure I can help but can point you to [Creating_Tables_with_Plugins](http://codex.wordpress.org/Creating_Tables_with_Plugins).

Viewing 1 replies (of 1 total)

The topic ‘My php code is not creating a table’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/my-php-code-is-not-creating-a-table/#post-1752344)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
