Building a plugin I'm trying to insert something in my DB but isn't works!

My code is like that:

global $wpdb;
$table_name = $wpdb->prefix."mytable"; 

I have a string in my $_POST["name"] and my database only have 2 columns: id, who is AUTO_INCREMENT and Name.

I don't know if I need do something more than the $wpdb->insert('xxxxxxx') but: Wordpress don't send me any error in PHP or SQL and don't insert anything in my database.


1 Answer 1


I would say the problem is first array. Change it to

    'name' => $_POST['name']

You can also use wpdb->show_error() or wpdb->print_error()

To Samuel Elh: wpdb->insert() can escape value itself

  • I'm looking for that error...thanks! I didn't see! Now works well
    – Marcos
    May 17, 2016 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.