title: PHP PDO Duplicate entry for key 'PRIMARY'
body: <p>I'm trying to insert values into different tables at once. new data has never been inserted before to any of these tables and I get inserted into the first table only then get this error</p>
  
  <pre><code>Duplicate entry 'example@mail.com' for key 'PRIMARY'
  </code></pre>
  
  <p>code</p>
  
  <pre><code>include("../connect.php");
  $this-&gt;con-&gt;exec('INSERT INTO users VALUES (null, "' . $this-&gt;email . '","' . $this-&gt;name . '","' . $pass . '",0,' . $this-&gt;isEmailConfirmed . ',"' . $this-&gt;token . '", "")');
  
  //insert into another database
  include("../another_directory/connect.php");
  $this-&gt;con-&gt;exec('INSERT INTO users  VALUES (null, "' . $this-&gt;email . '","' . $this-&gt;name . '","' . $pass . '",0,' . $this-&gt;isEmailConfirmed . ',"' . $this-&gt;token . '", "")');
  print_r($this-&gt;con-&gt;errorInfo());
  </code></pre>
  
  <p>null refers to the first field <code>user_id</code> which is <code>index</code> and set to <code>auto increment</code>. The email field is <code>primary key</code>. Now I'm trying to register users but the user get inserted into the first table only and cannot be inserted into the same table in the other database and get the duplicate primary error though it has never been added before.</p>
  
  <p>I tried the traditional way of insert</p>
  
  <pre><code>insert into users (field1, field2) values ($value1, $value2)
  </code></pre>
  
  <p>But I get the same error.</p>
  
  <p>How to solve this issue?</p>