title: Check if two times overlap
body: <p>I want to see if a time I read from a db overlaps with a time provided by a user.</p>
  
  <p>My database looks like this:</p>
  
  <pre><code>-----------------------------------------------
  |organiser|meeting_start|meeting_end|boardroom|
  -----------------------------------------------
  | John Doe| 1340193600  | 1340195400| big     |
  -----------------------------------------------
  </code></pre>
  
  <p>My code looks like this:</p>
  
  <pre><code>date_default_timezone_set('Africa/Johannesburg');
  $from = strtotime($_GET['meeting_date'] . ' ' . $_GET['meeting_start']);
  $to = strtotime($_GET['meeting_date'] . ' ' . $_GET['meeting_end']);
  $another_meeting = false;
  $meeting_date = strtotime($_GET['meeting_date']);
  $meeting_next = $meeting_date + 86400;
  
  $result = mysql_query("SELECT meeting_start, meeting_end FROM admin_boardroom_booking WHERE boardroom = '" . $_GET['boardroom'] . "' AND meeting_start &gt;= '" . $meeting_date . "' AND meeting_end &lt; '" . $meeting_next . "'")or die(mysql_error());
  while($row = mysql_fetch_array($result)) {
      $from_compare = $row['meeting_start'];
      $to_compare = $row['meeting_end'];
  
      $intersect = min($to, $to_compare) - max($from, $from_compare);
      if ( $intersect &lt; 0 )
          $intersect = 0;
  
      $overlap = $intersect / 3600;
      if ( $overlap &lt;= 0 ) {
          $another_meeting = true;
          break;
      }
  }
  
  if ($another_meeting)
      echo 'ERROR';
  </code></pre>
  
  <p>If I type two overlapping times on purpose, it doesn't echo error. What am I doing wrong?</p>