Home Showing Notice: Undefined property: wpdb::$insertid in D:\wamp\www\wordpress-4.7.1\wordpress\wp-includes\wp-db.php on line 684
Reply: 0

Showing Notice: Undefined property: wpdb::$insertid in D:\wamp\www\wordpress-4.7.1\wordpress\wp-includes\wp-db.php on line 684

user10259
1#
user10259 Published in September 19, 2018, 11:03 am

This question already has an answer here:

  • How to get last inserted row ID from wordpress database? 4 answers

I want to get last inserted id to update table based on this id. For that I used $wpdb->insert_id for getting the last inserted id. But get this issue Notice: Undefined property: wpdb::$insertid in D:\wamp\www\wordpress-4.7.1\wordpress\wp-includes\wp-db.php on line 684

this is my code. Someone please help

$parent_id=$template_load_data['id'];
         $wpdb->insert( 'wp_rxl_templates', array(
                'template_name' => $_POST['template_name_custom'],
                'template_content' => $post_content,
                'created_date' => current_time( 'mysql' ),
                'status' => 'active',
                'default_template'=>'false',
                'parent_template_id'=>''.$parent_id.'',
            ));
            $result_id = $wpdb->insertid;
 $result_data = "select wp_rxl where status ='active' NOT (id = '$result_id')";
share|improve this question

marked as duplicate by DarthJDG, brasofilo wordpress StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var $hover = $(this).addClass('hover-bound'), $msg = $hover.siblings('.dupe-hammer-message'); $hover.hover( function() { $hover.showInfoMessage('', { messageElement: $msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Apr 17 at 14:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It's $wpdb->insert_id – IsThisJavascript Apr 17 at 9:24
  • Thanks you its working now. I have one more doubt. how can update the table based on this id. the scenario is i need to insert this row as active and all other row expect last inserted row need to be inactive. – Meera S Nair Apr 17 at 9:29
  • @Mittul yes I used – Meera S Nair Apr 17 at 9:31
  • "select wp_rxl where status ='active' NOT (id = '$result_id')"; – Meera S Nair Apr 17 at 9:31
  • is this correct? – Meera S Nair Apr 17 at 9:32

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316245 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO