title: MySQL error with dates
body: <p>MySQL tells me I have a wrong syntax, but I don't know where. Can anyone help me?</p>
  
  <pre><code>$dt = $xml-&gt;item-&gt;parameter[2];
  $to = date('Y-m-d H:i:s',strtotime($dt));
  $query = sprintf("select * from me,val where group_id=%s AND m_id= me_id AND time_stamp &lt;= $to",mysql_real_escape_string($gid));
  $result= mysql_query($query) or die(mysql_error());
  
  while ($row=mysql_fetch_array($result)){
  </code></pre>
  
  <p>The parsing to a date works. Thanks in advance.</p>
  
  <blockquote>
    <p>Error: 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 '23:59:59' at line 1</p>
  </blockquote>