enter image description here I am writing a query for inserting data in to database but when I am printing query at output it turns into "SHOW COLUMNS from tbl_name" query. I am writing below query . But it executes like shown in image

$table_name1 = $wpdb->prefix . 'fullcontact';
    $sql1=$wpdb->insert( $table_name1, array(
        'status' => $status,
        'request_id' => $req_id,
        'likelihood' => $likelihood,
        'photos' => $photos,
        'chats' => $chats,
        'websites' => $websites,
        'fullname' => $fullname,
        'familyname' => $familyname,
        'givenname' => $givenname,
        'organisation' => $organisation,
        'normalizedlocation' => $normalizedlocation,
        'city' => $city,
        'state' => $state,
        'country' => $country,
        'age' => $age,
        'agerange' => $agerange,
        'gender' => $gender,
        'locationgeneral' => $locationgeneral,
        'socialprofiles' => $socialprofiles,
        'scores' => $scores,
        'topics' => $topics
    ) );

    //exit( var_dump( $wpdb->last_query ) );
  • 1
    Please elaborate on "printing query". What exactly are you doing and in what order?
    – Rarst
    Commented Jun 6, 2017 at 7:55
  • $table_name1 = $wpdb->prefix . 'fullcontact'; $sql1=$wpdb->insert( $table_name1, array( 'status' => $status, 'request_id' => $req_id, 'likelihood' => $likelihood ) ); $wpdb->show_errors(); $wpdb->print_error($sql1);
    – compoholic
    Commented Jun 6, 2017 at 8:56
  • i am printing this query by show_error() and print_error() function
    – compoholic
    Commented Jun 6, 2017 at 8:56
  • I don't quite follow what you are trying to do there. Why explicit print_error() with result of your query?
    – Rarst
    Commented Jun 6, 2017 at 9:05
  • can I mail you the pics plz ? I am hard stuck at this..it wud be kind if you help me.
    – compoholic
    Commented Jun 6, 2017 at 9:10

2 Answers 2


For anyone else finding this question. Wordpress seems to do a SHOW FULL COLUMNS query before executing the INSERT query. If it determines that the INSERT query would fail/store bad data, for example because the given data types would not fit in the column, it does not execute the insert query at all and return false.


  • Have you filled all fields that can not be null and do not have a default value
  • Does the data type for every field match the data type in the database
  • Does the data passed to the function violate any constraints? A string cannot be longer than the maximum length of the field you are trying to put it into. An integer field has a minimum and maximum value. Unsigned integers cannot contain negative values.
  • Exactly.. I had did this in past and it worked..!
    – compoholic
    Commented Jul 20, 2017 at 12:48
  • Appreciate this note, very helpful
    – Kender
    Commented Feb 13, 2023 at 18:13

Just had the same Problem, the fix was i tried to add varchar longer than the database field can hold. When changed the DB it workled again

  • thank You but it did'nt worked for me..anything else please ?
    – compoholic
    Commented Jun 6, 2017 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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