title: Uncaught exception 'PDOException' with message 'There is no active transaction'?
body: <p>This is the code i use to insert record. Whenever there is insert error , The subscriber table auto - inc number will still increase even i have roll back? What is the problem?  <strong>I just want the auto increment number not add when error occur</strong>.thanks a lot for help .</p>
  
  <pre><code>$conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $conn-&gt;setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
  $conn-&gt;beginTransaction();
  try {
  
      $email = $_POST['Email'];
      $FirstName = $_POST['FirstName'];
      $LastName = $_POST['LastName'];
  
  
      $query="INSERT INTO subscriber (Email,FirstName,LastName,CreateDate) VALUES (?,?,?,CURDATE())";
      $stmt = $conn-&gt;prepare($query);
  
  
      $stmt-&gt;bindParam(1, $email , PDO::PARAM_STR);
      $stmt-&gt;bindParam(2, $FirstName, PDO::PARAM_STR);
      $stmt-&gt;bindParam(3, $LastName, PDO::PARAM_STR);
      $stmt-&gt;execute();
      $conn-&gt;commit();
  
  }
  catch(PDOException $e)
      {
      $conn-&gt;rollBack();
      die ($e-&gt;getMessage()."&lt;a href='addSub.php'&gt;Back&lt;/a&gt;");
      }
  
  $conn-&gt;beginTransaction();
  try {
      $userID = $_SESSION['username'];
      $query="INSERT INTO list_sub (SubID,ListID) VALUES ('',$_SESSION[ListID])";
      $stmt = $conn-&gt;prepare($query);
      $stmt-&gt;execute();
      $conn-&gt;commit();
  
  }
  catch(PDOException $e)
      {
      $conn-&gt;rollBack();
      die ($e-&gt;getMessage()."&lt;a href='addSub.php'&gt;Back&lt;/a&gt;");
      }
  
  $conn = null;}
  </code></pre>