title: PDO lastInsertId issues, php
body: <p>I have tried lots of ways to get the last inserted ID with the code below (snipplet from larger class) and now I have given up.</p>
  
  <p>Does anyone know howto get PDO lastInsertId to work?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>    $sql = "INSERT INTO auth (surname, forename, email, mobile, mobilepin, actlink, regdate) VALUES (:surname, :forename, :email, :mobile, :mobpin, :actlink, NOW())";
  $stmt = $this-&gt;dbh-&gt;prepare($sql);
  if(!$stmt) {
   return "st";
  }
  
  $stmt-&gt;bindParam(':surname', $this-&gt;surname);
  $stmt-&gt;bindParam(':forename', $this-&gt;forename);
  $stmt-&gt;bindParam(':email', $this-&gt;email);
  $stmt-&gt;bindParam(':mobile', $this-&gt;mobile);
  $stmt-&gt;bindParam(':mobpin', $this-&gt;mobilePin);
  $stmt-&gt;bindParam(':actlink', $this-&gt;actlink);
  
  $result = $stmt-&gt;execute();
  //return var_dump($result);
  $arr = array();
  $arr = $stmt-&gt;errorInfo();
  $_SESSION['record'] = 'OK' . $dbh-&gt;lastInsertId();
  $arr .= $_SESSION['record'];
  return $arr;
  </code></pre>