title: Getting an error when i run this pagination page demo in php?
body: <pre><code>&lt;?php
   include(&quot;include/db.inc.php&quot;);
  
    $sql = mysql_query(&quot;SELECT * FROM emp&quot;);
    $nr = mysql_num_rows($sql);
  
   if(isset($_GET['page'])){
    $pn = preg_replace('#[^0-9]#i','',$_GET['page']);
   }else{
    $pn = 1;
   }
  
  $itemPerPage = 10;
  $lastPage = ceil($nr/$itemPerPage);
  if($pn &lt; 1){
  $pn = 1;
  }elseif($pn &gt; $lastPage){
  $pn = $lastPage;
  }
  
  $centerPage = '';
  $sub1 = $pn - 1;
  $sub2 = $pn - 2;
  $add1 = $pn + 1;
  $add2 = $pn + 2;
  
  if($pn == 1){
  $centerPage .= '&amp;nbsp;&lt;span class=&quot;pagNumActive&quot;&gt;'. $pn .'&lt;/span&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $add1 .'&quot;&gt;'. $add1 .'&lt;/a&gt;&amp;nbsp;';
  }elseif($pn == $lastPage){
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $sub1 .'&quot;&gt;'. $sub1 .'&lt;/a&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;span class=&quot;pagNumActive&quot;&gt;'. $pn .'&lt;/span&gt;&amp;nbsp;';
  }elseif($pn == 2 &amp;&amp; $pn &lt; ($lastPage - 1)){
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $sub2 .'&quot;&gt;'. $sub2 .'&lt;/a&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $sub1 .'&quot;&gt;'. $sub1 .'&lt;/a&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;span class=&quot;pagNumActive&quot;&gt;'. $pn .'&lt;/span&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $add1 .'&quot;&gt;'. $add1 .'&lt;/a&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $add2 .'&quot;&gt;'. $add2 .'&lt;/a&gt;&amp;nbsp;';
  }elseif($pn &gt; 1 &amp;&amp; $pn &lt; $lastPage){
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $sub1 .'&quot;&gt;'. $sub1 .'&lt;/a&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;span class=&quot;pagNumActive&quot;&gt;'. $pn .'&lt;/span&gt;&amp;nbsp;';
  $centerPage .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='. $add1 .'&quot;&gt;'. $add1 .'&lt;/a&gt;&amp;nbsp;';
  }
  
  $paginationDisplay = '';
  if($lastPage != '1'){
  $paginationDisplay .= 'Page &lt;strong&gt;'.$pn.'&lt;/strong&gt; of '.$lastPage.'&amp;nbsp;&amp;nbsp;&amp;nbsp;';
  if($pn != 1){
      $previous = $pn - 1;
      $paginationDisplay .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page=1&quot;&gt;First&lt;/a&gt; ';
      $paginationDisplay .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='.$previous.'&quot;&gt;Back&lt;/a&gt;';
  }
  $paginationDisplay .= '&lt;span class=&quot;paginationNumbers&quot;&gt;'.$centerPage.'&lt;/span&gt;';
  if($pn != $lastPage){
      $nextPage = $pn+1;
      $paginationDisplay .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='.$nextPage.'&quot;&gt;Next&lt;/a&gt;';
      $paginationDisplay .= '&amp;nbsp;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?page='.$lastPage.'&quot;&gt;Last&lt;/a&gt; ';
  }
   }
  </code></pre>
  <p><strong>I got error here whenever i try to run this demo page...</strong> Here are the 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 'LIMIT0,10' at line 1</p>
  <p>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in G:\Backup\US\root\php-db\dashboard-2.php on line 87</p>
  </blockquote>
  <pre><code>$limit = 'LIMIT'.($pn-1)*$itemPerPage.','.$itemPerPage;
  $sql2 = mysql_query(&quot;SELECT * FROM emp ORDER BY emp_id $limit&quot;);
  
  $outputList = '';
  while($row = mysql_fetch_array($sql2)){ 
  $id = $row[&quot;emp_id&quot;];
  $fname = $row[&quot;emp_fname&quot;];
  $lname = $row[&quot;emp_lname&quot;];
  $email = $row[&quot;emp_email&quot;];
  $desc = $row[&quot;emp_desc&quot;];
  
  $outputList = '
  &lt;tr&gt;
   &lt;td&gt;'.$id.'&lt;/td&gt;
   &lt;td&gt;'.$fname.'&lt;/td&gt;
   &lt;td&gt;'.$lname.'&lt;/td&gt;
   &lt;td&gt;'.$email.'&lt;/td&gt;
   &lt;td&gt;'.$desc.'&lt;/td&gt;
   &lt;td&gt;
   &lt;a href=&quot;view.php?id='.$id.'&quot; title=&quot;View details...&quot;&gt;&lt;img src=&quot;assets/img/view.png&quot; alt=&quot;View&quot; /&gt;&lt;/a&gt; | &lt;a href=&quot;edit.php?id='.$id.'&quot; title=&quot;Edit details...&quot;&gt;&lt;img src=&quot;assets/img/edit.png&quot; alt=&quot;Edit&quot; /&gt;&lt;/a&gt; | &lt;a href=&quot;delete.php?id='.$id.'&quot; title=&quot;Delete details...&quot;&gt;&lt;img src=&quot;assets/img/delete.png&quot; alt=&quot;Delete&quot; /&gt;&lt;/a&gt;&lt;/td&gt;
   &lt;/tr&gt;
   '; 
   }
   ?&gt;
   &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;
      Employee dashboards!!!!
      &lt;/title&gt;
      &lt;style type=&quot;text/css&quot;&gt;
   .pagNumActive {
       color: #000;
       border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px;
   }
   .paginationNumbers a:link {
       color: #000;
       text-decoration: none;
       border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
   }
   .paginationNumbers a:visited {
       color: #000;
       text-decoration: none;
       border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
   }
   .paginationNumbers a:hover {
       color: #000;
       text-decoration: none;
       border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px;
   }
   .paginationNumbers a:active {
       color: #000;
       text-decoration: none;
       border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px;
   }
   &lt;/style&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;center&gt;
  &lt;?php echo $paginationDisplay; ?&gt;
  &lt;/center&gt;   
      &lt;table cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; border=&quot;4&quot; width=&quot;100%&quot; &gt;
          &lt;thead&gt;
   &lt;tr&gt;
   &lt;th&gt;Employee ID&lt;/th&gt;
   &lt;th&gt;Employee First Name&lt;/th&gt;
   &lt;th&gt;Employee Last Name&lt;/th&gt;
   &lt;th&gt;Employee Email ID&lt;/th&gt;
   &lt;th&gt;Employee Bio&lt;/th&gt;
   &lt;th&gt;Actions&lt;/th&gt;
   &lt;/tr&gt;
       &lt;/thead&gt;
       &lt;tbody&gt;    
          &lt;?php echo $outputList; ?&gt;
              &lt;/tbody&gt;
           &lt;/table&gt;
      &lt;center&gt;
          &lt;?php echo $paginationDisplay; ?&gt;
      &lt;/center&gt;       
       &lt;/body&gt;
       &lt;/html&gt;
  </code></pre>