• Resolved iperez_genius

    (@iperez_genius)


    i am trying to insert data into my own table in the DB

    this is the line of code i am using

    $wpdb->insert($wpdb->something, $data);

    ‘something’ is the table name in the DB and the $data array has the correct field names in the correct order with the correct value types

    however the records are not being inserted into the DB.

    do i need to add the table name into wordpress’s php files somewhere or is the table list dynamic?

    Any help would be greatly apprecaited

    Ilan

Viewing 5 replies - 1 through 5 (of 5 total)
  • Might want to check the insert and prepare discussion in wpdb.

    hi iperez_genius,
    check whether you have added any prefix to the wordpress tables… like
    $prefix=’wp_’;
    so the table name is wp_posts

    Thread Starter iperez_genius

    (@iperez_genius)

    magickman5 you were partly correct

    even though i updated the table name to be

    wp_something the table name wasn’t in the query so instead of using

    $wpdb->insert($wpdb->something, $data);
    i used
    $wpdb->insert('wp_something', $data);

    that fixed the problem…i have a new problem though. Because i have added something to the comment.php and wp_new_comment.php when i try to delete a comment i receive an error…i am looking into that now. here is the error

    Fatal error: Call to undefined function wp_trash_comment() in /home/sydneyme/public_html/dir/wp-admin/admin-ajax.php on line 217

    hi iperez_genius,

    thats what i actually meant. The syntax for insert is

    $wpdb->insert( ‘table’, array( ‘column1’ => ‘value1’, ‘column2’ => 123 ), array( ‘%s’, ‘%d’ ) )

    so as i told you “check whether you have added any prefix to the wordpress tables… like
    $prefix=’wp_’;
    ” at the time of installation.

    but anyways we got it correct…cheers and i will look into the next issue also.

    Thread Starter iperez_genius

    (@iperez_genius)

    so it turns out that the trash function some how got deleted from the comment.php file…

    i have no idea why…but i added the functions back in and all is well so…

    everything is resolved!

    thanks for all the help.

    Ilan

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

The topic ‘DB insertion’ is closed to new replies.