title: Proper insert of date in MySql date field
body: <p>I am posting data for event in this format via ajax:</p>
  
  <pre><code>doctor=100&amp;date=2015-04-30&amp;rCheck=1&amp;rDate=2015-05-12&amp;fromTime=21%3A35&amp;toTime=22%3A40&amp;status=open
  </code></pre>
  
  <p>I am getting it like this with php</p>
  
  <pre><code>$date = $_POST['date'];
  $fromHours = $_POST['fromHours'];
  $fromMinutes = $_POST['fromMinutes'];
  $toHours = $_POST['toHours'];
  $toMinutes = $_POST['toMinutes'];
  $fromTime = $_POST['fromTime'];
  $toTime = $_POST['toTime'];
  $start = $date.' '.$fromTime.':00';
  $end = $date.' '.$toTime.':00';
  $status = $_POST['status'];
  $doctor = $_POST['doctor'];
  
  if($_POST['rCheck']==1){
      $repeat = $_POST['rDate'];
  }else{
      $repeat = '0000-00-00';
  }
  </code></pre>
  
  <p>When I echo any of that variables I get correct result.</p>
  
  <p>I am inserting data in database like this:</p>
  
  <pre><code>$query = 'INSERT INTO events (start,end,doctor,status,repeat) VALUES ("'.$start.'","'.$end.'","'.$doctor.'","'.$status.'","'.$repeat.'")';
  $result = mysqli_query($db, $query) or die (mysqli_error($db));
  </code></pre>
  
  <p>Now main problem is <code>$repeat</code> because without it everything is inserted without problem but with <code>$repeat</code> I get this error:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'repeat) VALUES ("2015-04-30 21:35:00","2015-04-30 22:40:00","100","offen","2015-' at line 1</p>
  </blockquote>
  
  <p>Insert stops after fifth '-' character. Even if <code>$repeat</code> is <code>0000-00-00</code><br>
  Field for that in database is date field in format <code>0000-00-00</code><br>
  I really don't know where problem is.<br>
  Thank you for helping.</p>