title: MySQL server version for the right syntax to use near 'ORDER BY
body: <p>I want to navigate records with next &amp; prev buttons, But i gor the following error</p>
  
  <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 'ORDER BY Sr_no DESC LIMIT 1' at line 1"
  Pls help me to resolve this error</p>
  
  <p>MY code is </p>
  
  <pre><code>&lt;?php
  $id = $_GET['Sr_no'];
  $id = $currentid;
  $prevquery = "SELECT Sr_no, Entry_Date, Agent_Name, Process_Name, Donar_Name,Company_Name,Designation, Add1, Add2, Add3, Pincode, City, Contact_no,Mobile_no,Nearest_station,Suburbans, Pickup_time,Pickup_Date, Confirmation_Status,Last_Yr_Contribution,Pickup_Amount,Final_Donate_amt,Final_Status,DOB,Email_Id,Chq_Deposite_Date,Form_No,Cheque_Date,Cheque_No,Bank_Name,Chq_Amount,Pan_No,MICR_No,CLR_Loc,Batch_File,Donar_Code FROM leads WHERE Sr_no &lt; $currentid ORDER BY Sr_no DESC LIMIT 1";
  $prevresult = mysql_query($prevquery) or die(mysql_error());
  while ($prevrow = mysql_fetch_array($prevresult)) {
      $previd = $prevrow['Sr_no'];
  }
  $nextquery = "SELECT Sr_no, Entry_Date, Agent_Name, Process_Name, Donar_Name,Company_Name,Designation, Add1, Add2, Add3, Pincode, City, Contact_no, Mobile_no,Nearest_station,Suburbans, Pickup_time, Pickup_Date, Confirmation_Status, Last_Yr_Contribution, Pickup_Amount,Final_Donate_amt,Final_Status,DOB,Email_Id,Chq_Deposite_Date,Form_No,Cheque_Date,Cheque_No,Bank_Name,Chq_Amount,Pan_No,MICR_No,CLR_Loc,Batch_File,Donar_Code FROM  leads WHERE Sr_no &lt; $currentid ORDER BY Sr_no DESC LIMIT 1";
  $nextresult = mysql_query($nextquery) or die(mysql_error());
  while ($nextrow = mysql_fetch_array($nextresult)) {
      $nextid = $nextrow['Sr_no'];
  }
  ?&gt;
  
  &lt;a href="edit1.php?Sr_no=&lt;?php echo $previd; ?&gt;"&gt;Previous&lt;/a&gt;
  &lt;a href="edit1.php?Sr_no&lt;?php echo $nextid; ?&gt;"&gt;Next&lt;/a&gt;
  </code></pre>