$wpdb->insert not working. No Error Msg

Hopefully, you have defined the global variable $wpdb.

If your $wpdb is not working, and also not showing any error then you must try these three steps.

  1. Print your error using with errors functions.

    echo $wpdb->last_error;

    or

    echo $wpdb->show_errors;

  2. If no error is visible then you must print your last query using with last query function.

    echo $wpdb->last_query;

  3. Copy and paste your last query in your Phpmyadmin > Your Database -> Table -> SQL tab, click on the Go button, and you will definitely get proper solutions(errors) in it.


If you want to get the last error and last query you can use this properties of $wpdb object:

$wpdb->last_error 

will show you the last error, if you got one.

$wpdb->last_query 

will assist you with showing the last query (where the error occurred)

I hope this will help you out.


https://core.trac.wordpress.org/ticket/32315

One of the columns inputs may be larger than the column is. Wordpress detects this and will not even send the query to the DB.

The Diff there shows a patch for wp-db you can put in to get more information in the last_error message so it will not be empty.

enter image description here


Maybe your config hides error showing. Have you tried $wpdb->print_error();?