JavaScript undefined last inserted id

I need to get last inserted id

   $stmt = $db->query("SELECT LAST_INSERT_ID();");
   $row = $stmt->fetch();
   echo $row['id'];

js

    success: function(data) {
        console.log(data);
}

Result: undefined !

Answer:1

You must assign the proper alias

$stmt = $db->query("SELECT LAST_INSERT_ID() as id;");
$row = $stmt->fetch();
echo $row['id'];

otherwise echo $row['id'] is empty

Answer:2

// Browser onresize event window.onresize = function () { scope.$apply(); }; scope.render = function (data) { //debugger //var ...

// Browser onresize event window.onresize = function () { scope.$apply(); }; scope.render = function (data) { //debugger //var ...

  1. google chart legend click hide
  2. bokeh click legend to hide

I was trying to get a dynamic dependent select list using AJAX, but unable to get the second list. Here is my code. gethint.php is working fine. I don't know where I am doing wrong. <html> ...

I was trying to get a dynamic dependent select list using AJAX, but unable to get the second list. Here is my code. gethint.php is working fine. I don't know where I am doing wrong. <html> ...

  1. visual basic select dynamic range

I have this handler that I built to handle $http requests. It looks like this: .service('ApiHandler', ['$q', '$http', '$injector', 'apiUrl', 'ErrorService', 'toastr', function ($q, $http, $injector, ...

I have this handler that I built to handle $http requests. It looks like this: .service('ApiHandler', ['$q', '$http', '$injector', 'apiUrl', 'ErrorService', 'toastr', function ($q, $http, $injector, ...

  1. angularjs interceptor responseerror
  2. angularjs http interceptor responseerror
  3. angularjs interceptor response error handling

My first question here :) I'm porting my site to Angular (I'm new to it) and wondering if I'd be able to keep my pure CSS modal dialogue box while using ui-router. In HTML it looks like this: &...

My first question here :) I'm porting my site to Angular (I'm new to it) and wondering if I'd be able to keep my pure CSS modal dialogue box while using ui-router. In HTML it looks like this: &...