Title: database insert problem
Last modified: August 20, 2016

---

# database insert problem

 *  Resolved [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * (@muxahuk1214)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/database-insert-problem/)
 * Hello,
 * I have created new DB table. There’s 3 colls, id (auto incriment), name, metabox.
   Both name and metabox are varchar(255).
    Trying to fill it with rows, but metabox
   coll always shows 0 (ziro).
 * Checked colls name in function that inserts rows, metabox is writen correctly.
   the function recives the value which must be inserted in metabox coll (chacked
   also).
 * Don’t know what might go wrong.
    Help plese! Here’s the code I have:
 * Table creation
 *     ```
       $sql = "CREATE TABLE $pages (
           id mediumint(9) NOT NULL AUTO_INCREMENT,
           name varchar(255) NOT NULL,
           metabox varchar(255) NOT NULL,
           UNIQUE KEY id (id,name)
           );";
       ```
   
 * inserting row
 *     ```
       global $wpdb;
           $postTypeName = $_POST['name'];
           $metaname = $_POST['metaname'];
           if($wpdb->insert( 'wp_ewtc_pages',array('name' => $postTypeName,'metabox' => $metaname),array('%s','%d'))) {
               die('done');
           } else {
               die('problem');
           }
       ```
   
 * Working on localhost (on my PC, using Open Server on Windows 7 x64)
    Wordpress
   version 3.4.1

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Chandan Kumar](https://wordpress.org/support/users/chandanonline4u/)
 * (@chandanonline4u)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/database-insert-problem/#post-2967419)
 * I have made %d to %s and here is the code:
 *     ```
       $wpdb->insert( 'wp_ewtc_pages',array('name' => $postTypeName,'metabox' => $metaname),array('%s','%s'))
       ```
   
 * Note: %d denotes digit/numeric value and you have assigned metabox varchar.
 *  Thread Starter [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * (@muxahuk1214)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/database-insert-problem/#post-2967423)
 * thanks a lot!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘database insert problem’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [row](https://wordpress.org/support/topic-tag/row/)
 * [rows](https://wordpress.org/support/topic-tag/rows/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Mihail Semjonov](https://wordpress.org/support/users/muxahuk1214/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/database-insert-problem/#post-2967423)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
