title: Error MySQL server version for the right syntax to use near '-20, 20' at line 1
body: <p>How to fix 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 '-20, 20' at line 1</p>
  </blockquote>
  
  <p>The same script in my website is working properly but I uploaded to another server which is Windows server and received this error.</p>
  
  <pre><code>&lt;?php
  
  //connect to database
  mysql_connect('xyz.ipowermysql.com','itomi','password.');
  mysql_select_db('itomi');
  
  $max_results = 20;
  $from = (($page * $max_results) - $max_results);
  
  
  if(empty($_POST)) {
      $query = "SELECT * FROM `itomi` WHERE `ntitle` LIKE '".$letter."%' ORDER BY `ntitle` ASC LIMIT $from, $max_results";
  } 
  $result = mysql_query("SET NAMES utf8"); //the main trick
  $result = mysql_query($query) or die(mysql_error());
  $rows = mysql_num_rows($result);
  
  echo "&lt;table class='hovertable' border='1' cellpadding='0' cellspacing='0'&gt;";
  echo "&lt;tr&gt;&lt;th&gt;Keyword&lt;/th&gt;&lt;th&gt;Title&lt;/th&gt;&lt;th&gt;Detail&lt;/th&gt;&lt;/tr&gt;";
  
  if ($rows &gt; 0) {
      while($row = mysql_fetch_array($result)) {
          echo "&lt;tr&gt;&lt;td&gt;";
          echo '&lt;a href="detail.php?id=' . $row['id'] . '" class="style1"&gt;' .$row['ntitle'].' &lt;/a&gt;';
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['ndetails'];
          echo "&lt;/td&gt;&lt;td&gt;";
          echo $row['counter'];
          echo "&lt;/td&gt;&lt;/tr&gt;";
      }
  } else {
      echo "&lt;tr&gt;&lt;td colspan=\"5\"&gt;No results found!&lt;/td&gt;&lt;/tr&gt;";
  }
  
  echo "&lt;/table&gt;";
  
  // Figure out the total number of results in DB: 
  $total_results = mysql_result(mysql_query("SELECT COUNT(*) as ntitle FROM itomi ORDER BY ntitle ASC"),0);
  
  // Figure out the total number of pages. Always round up using ceil() 
  $total_pages = ceil($total_results / $max_results);
  
  // Build Page Number Hyperlinks 
  echo "&lt;p class=\"style1\"&gt;Pages: ";
  
  // Build Previous Link 
  if($page &gt; 1){ 
      $prev = ($page - 1); 
      echo "&lt;a href=\"".$_SERVER['php_SELF']."?page=$prev&amp;letter=$letter\" class=\"style1\"&gt;Previous&lt;/a&gt; "; 
  }
  
  for($i = 1; $i &lt;= $total_pages; $i++){ 
      if(($page) == $i){ 
          echo "$i "; 
      } else { 
          echo " "; 
      }
  }
  
  
  // Build Next Link 
  if($page &lt; $total_pages){ 
      $next = ($page + 1); 
      echo "&lt;a href=\"".$_SERVER['php_SELF']."?page=$next&amp;letter=$letter\" class=\"style1\"&gt;Next&lt;/a&gt;"; 
  } 
  echo "&lt;/p&gt;";
  
  mysql_close(); 
  </code></pre>