$wpdb->insert not working. No Error Msg

后端 未结 4 894
陌清茗
陌清茗 2021-02-19 18:29

Got the lower portion here sorted, but now there\'s an issue when it inserts the record. I have the NULL value for file formatted as %s fo

相关标签:
4条回答
  • 2021-02-19 18:54

    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.

    0 讨论(0)
  • 2021-02-19 18:55

    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.

    0 讨论(0)
  • 2021-02-19 19:04

    Hopefully, you define global variable = $wpdb.

    If your $wpdb 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 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 Go button, you will definitely get proper solutions(errors) in it.

    Thanks,

    Rocky Mehta.

    0 讨论(0)
  • 2021-02-19 19:06

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

    0 讨论(0)
提交回复
热议问题