title: inserting date using PDO and php
body: <p>I'm trying to insert into a table, I have managed this using the same syntax for another query but this fails, the only difference is that this contains date information. Can anyone spot the problem?</p>
  
  <p>The date is in this format: 2016-07-07.</p>
  
  <pre><code>try {
  $sql2 = "INSERT INTO excavation.contexts_spatial 
      (area_easting, 
      area_northing, 
      context_number, 
      open_date,
      close_date,
      excavation_method,
      contamination,
      zooarchaeology_comments,
      ceramic_comments) VALUES (
      :area_easting, 
      :area_northing, 
      :context_number, 
      :open_date, 
      :close_date, 
      :excavation_method,
      :contamination,
      :zooarchaeology_comments,
      :ceramic_comments)";
  
  $stmt2 = $conn-&gt;prepare($sql2);
  
  // prepare sql and bind parameters
  $stmt2-&gt;bindParam(':area_easting', $area_easting, PDO::PARAM_INT);       
  $stmt2-&gt;bindParam(':area_northing', $area_northing, PDO::PARAM_INT); 
  $stmt2-&gt;bindParam(':context_number', $nextContext, PDO::PARAM_INT);
  $stmt2-&gt;bindParam(':open_date', $open_date, PDO::PARAM_STR);
  $stmt2-&gt;bindParam(':close_date', $close_date, PDO::PARAM_STR);
  $stmt2-&gt;bindParam(':excavation_method', $excavation_method, PDO::PARAM_STR);
  $stmt2-&gt;bindParam(':contamination', $contamination, PDO::PARAM_STR);
  $stmt2-&gt;bindParam(':zooarchaeology_comments', $excavation_method, PDO::PARAM_STR);
  $stmt2-&gt;bindParam(':ceramic_comments', $excavation_method, PDO::PARAM_STR);
  
  //$stmt2-&gt;execute(); 
  
  // insert a row
  $area_easting = $_SESSION['area_easting'];
  $area_northing = $_SESSION['area_northing'];
  $nextContext = $_SESSION['nextContext'];
  $open_date = $_SESSION['dateOpen'];
  $close_date = $_SESSION['dateClose'];
  $excavation_method = $_SESSION['excavationMethod'];
  $contamination = $_SESSION['contamination'];
  $zooarchaeology_comments = $_SESSION['zooarchaeologyComments'];
  $ceramic_comments = $_SESSION['ceramicComments'];
  $stmt2-&gt;execute();
  
  echo "New records created successfully in contexts spatial&lt;br /&gt;";
  }
  catch(PDOException $e)
  {
   echo "Error: " . $e-&gt;getMessage();
  }
  </code></pre>