title: 1064: You have an error in your SQL syntax near ''
body: <blockquote>
    <p>1064: 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 '' at line 4<br />SELECT a.* FROM <code>ws_items</code> a WHERE 1 AND <code>enabled</code>=1 AND <code>visible</code>=1 ORDER BY <code>created</code> DESC LIMIT 0, </p>
  </blockquote>
  
  <p>I searched the website, but none matches my query. I have no idea on how to use mysql, but I really need to solve this problem...
   Maybe someone here knows the solution</p>
  
  <pre><code> if ($params["page_name"]=="index")
          {
  
              $filter = "";
              if ($_SESSION['user_data']['type']!="admin")
              {
                  $filter = " AND `enabled`=1 AND `visible`=1 ";
              }
  
              $sql = "SELECT a.* FROM 
              `".DB_PREFIX."items` a WHERE 1 $filter 
              ORDER BY `created` DESC 
              LIMIT ".($_SESSION['itemsPerPage']*($page-1)).",".$_SESSION['itemsPerPage'];
  
              $items = $DB-&gt;getAll($sql); 
              for($i=0; $i&lt;count($items); $i++)
              {
                  $items[$i][third] = "";
  
                  $items[$i][thumb_rating] = rating_bar($items[$i]['id'], '5', 'static');
                  if($i%3==2)
                      $items[$i][third] = 'style="margin-right:0;"';
              }
  
              $smarty-&gt;assign("items", $items);
  
              $sql = "SELECT COUNT(a.id) as `total` FROM 
              `".DB_PREFIX."items` a WHERE 1 $filter 
              ";
  
              $items = $DB-&gt;get($sql);
              $total = $items['total'];
  
              $smarty-&gt;assign("pagination", $DB-&gt;show_pagination($total, $page, $_SESSION['itemsPerPage']));
  
              $output = $this-&gt;display(__FILE__, 'latestwallpapers.tpl');
          }
          return $output;
      }
  </code></pre>