title: Insert into 2 tables with PDO MySQL
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5178697/mysql-insert-into-multiple-tables-database-normalization">MySQL Insert into multiple tables? (Database normalization?)</a>  </p>
  </blockquote>
  
  
  
  <p>im trying to use PDO to insert my records into 2 tables, I have the following</p>
  
  <pre><code>try {
    // Connect and create the PDO object
   $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
  $conn-&gt;exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
   $sql = "INSERT INTO `directory` (`First_Name`,`Surname`,`Nicknames`) 
        VALUES (:firstname, :surname, :nicknames) ";
  
   $statement = $conn-&gt;prepare($sql);
   $statement-&gt;bindValue(":firstname", $firstname);
   $statement-&gt;bindValue(":surname", $surname);
   $statement-&gt;bindValue(":nicknames", $nicknames);
  
  
   $count = $statement-&gt;execute();
  
    $conn = null;        // Disconnect
  }
  catch(PDOException $e) {
    echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>that inserts my data into 1 table fine, if I use (What i presume to be corrct) however my page doesnt render and no source code is output? Can anybody see if im going wrong anywhere?</p>
  
  <pre><code>try {
    // Connect and create the PDO object
   $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
  $conn-&gt;exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
   $sql = "INSERT INTO `directory`, `nicknames`  (`First_Name`,`Surname`,`Nicknames`) 
        VALUES (:firstname, :surname, :nicknames) ";
  
   $statement = $conn-&gt;prepare($sql);
   $statement-&gt;bindValue(":firstname", $firstname);
   $statement-&gt;bindValue(":surname", $surname);
   $statement-&gt;bindValue(":nicknames", $nicknames);
  
  
   $count = $statement-&gt;execute();
  
    $conn = null;        // Disconnect
  }
  catch(PDOException $e) {
    echo $e-&gt;getMessage();
  }
  </code></pre>