title: It is not inserting a date in the database
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7793893/php-mysql-query-with-inserting-date-fails">php/Mysql query with inserting date fails</a>  </p>
  </blockquote>
  
  
  
  <p>I have a datepicker code below:</p>
  
  <pre><code>         $(function() {
          $( "#datepicker" ).datepicker({minDate: 0, 
                              dateFormat: "dd-mm-yy"
  });
  });
  </code></pre>
  
  <p>As you can see the format of the date when it is displayed in the datepicker textbox ('dateChosen') is 'dd-mm-yy' which is like this (20-05-2012).</p>
  
  <p>But when I try and insert the date in the 'SessionDate' field, instead of displaying '2012-05-20' in the database, it keeps displaying '0000-00-00'. Why is it doing this?</p>
  
  <p>What I want is the textbox format to remain the same but when the date is inserted into the SessionDate table, then I want it inserted as '2012-05-20' and not as '0000-00-00'.</p>
  
  <p>Below is code for the insert ($_POST['dateChosen'] is the post method which posts the date):</p>
  
  <pre><code>$sql="INSERT INTO Session (SessionDate)
  VALUES
  (' ". mysql_real_escape_string( $_POST['dateChosen'] ) . "'
  )";
  
  mysql_query($sql);
  </code></pre>