title: How to insert into more than one MySQL tables use prepared statment
body: <p>Tried to write two statment in one php file use prepared statment, i create two statment in one php file... here is my php file...</p>
  
  <pre><code> &lt;?php
  
  require("config.inc.php");
  
  
  if (!empty($_POST)) {
  
  
      if (empty($_POST['name'])|| empty($_POST['password'])) {
  
  
          $response["success"] = 0;
          $response["message"] = "Please Enter Both a Username and Password.";
  
          die(json_encode($response));
      }
  
  
      $query        = " SELECT 1 FROM nama WHERE name= :name";
      $query_params = array(
          ':name' =&gt; $_POST['name']
      );
    $queryT        = " SELECT 1 FROM ProfilSiswa WHERE nama_lengkap= :nameT";
      $query_paramsT = array(
          ':nameT' =&gt; $_POST['nama_lengkap']
      );
  
      try {
          // These two statements run the query against your database table. 
          $stmt   = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($query_params);
          $stmtT   = $db-&gt;prepare($queryT);
          $resultT = $stmt-&gt;execute($query_paramsT);
  
      }
      catch (PDOException $ex) {
  
  
          $response["success"] = 0;
          $response["message"] = "Database Error1. Please Try Again!";
          die(json_encode($response));
      }
  
  
  
      $query = "INSERT INTO nama(name, info) VALUES ( :name, :info) ";
      $queryT = "INSERT INTO ProfilSiswa(nama_lengkap) VALUES ( :nameT) ";
  
  
  $query_params = array(
          ':name' =&gt; $_POST['name'],
          ':info' =&gt; $_POST['info']
      );
  
  $query_paramsT = array(
          ':nameT' =&gt; $_POST['nama_lengkap']
      );
  
  
      try {
          $stmt   = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($query_params);
  
          $stmtT   = $db-&gt;prepare($queryT);
          $resultT = $stmt-&gt;execute($query_paramsT);
  
      }
      catch (PDOException $ex) {
  
          $response["success"] = 0;
          $response["message"] = "Database Error2. Please Try Again!";
          die(json_encode($response));
      }
  
  
    ...
  </code></pre>
  
  <p>When I use that statement the values isn't insert to the tables and not showing an error when try to execute... </p>