title: Right syntax to use near order by id desc limit 1
body: <p>If the code is executed, it shows the error:</p>
  
  <blockquote>
    <p>check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY ID DESC limit 1'</p>
  </blockquote>
  
  <p>Like in the following example:</p>
  
  <pre><code>$prevquery = "SELECT  * FROM $tbl_name WHERE  ID &lt; $ID ORDER BY ID DESC limit 1";
  $prevresult= mysql_query($prevquery) or die(mysql_error());
  
  while($prevrow = mysql_fetch_row($prevresult))
  {
  
    displaying the previous ID:-
    $prevID = $prevrow['ID'];
  }
  </code></pre>
  
  <p>What should one do to prevent this?</p>