Support » Fixing WordPress » database insert problem

  • Resolved Mihail Semjonov

    (@muxahuk1214)


    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)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘database insert problem’ is closed to new replies.