Index: /trunk/admin/cat_perm.php
===================================================================
--- /trunk/admin/cat_perm.php	(revision 4333)
+++ /trunk/admin/cat_perm.php	(revision 4334)
@@ -60,5 +60,5 @@
   FROM '.CATEGORIES_TABLE.'
   WHERE status = \'private\'
-  LIMIT 0 OFFSET 1
+  LIMIT 1
 ;';
 
Index: /trunk/admin/element_set_global.php
===================================================================
--- /trunk/admin/element_set_global.php	(revision 4333)
+++ /trunk/admin/element_set_global.php	(revision 4334)
@@ -475,11 +475,9 @@
   WHERE id IN ('.implode(',', $page['cat_elements_id']).')
   '.$conf['order_by'].'
-  LIMIT '.$page['start'].' OFFSET '.$page['nb_images'].'
-;';
-  //echo '<pre>'.$query.'</pre>';
+  LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].'
+;';
   $result = pwg_query($query);
 
   // template thumbnail initialization
-
   while ($row = pwg_db_fetch_assoc($result))
   {
Index: /trunk/admin/element_set_unit.php
===================================================================
--- /trunk/admin/element_set_unit.php	(revision 4333)
+++ /trunk/admin/element_set_unit.php	(revision 4334)
@@ -197,5 +197,5 @@
   WHERE id IN ('.implode(',', $page['cat_elements_id']).')
   '.$conf['order_by'].'
-  LIMIT '.$page['start'].' OFFSET '.$page['nb_images'].'
+  LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].'
 ;';
   $result = pwg_query($query);
Index: /trunk/admin/include/functions.php
===================================================================
--- /trunk/admin/include/functions.php	(revision 4333)
+++ /trunk/admin/include/functions.php	(revision 4334)
@@ -598,5 +598,5 @@
   WHERE category_id = '.$category_id.'
   ORDER BY '.DB_RANDOM_FUNCTION.'()
-  LIMIT 0 OFFSET 1
+  LIMIT 1
 ;';
     list($representative) = pwg_db_fetch_row(pwg_query($query));
Index: /trunk/admin/include/functions_history.inc.php
===================================================================
--- /trunk/admin/include/functions_history.inc.php	(revision 4333)
+++ /trunk/admin/include/functions_history.inc.php	(revision 4334)
@@ -162,5 +162,5 @@
 ;';
 
-  // LIMIT '.$page['start'].' OFFSET '.$conf['nb_logs_page'].'
+  // LIMIT '.$conf['nb_logs_page'].' OFFSET '.$page['start'].'
 
   $result = pwg_query($query);
Index: /trunk/admin/rating.php
===================================================================
--- /trunk/admin/rating.php	(revision 4333)
+++ /trunk/admin/rating.php	(revision 4334)
@@ -177,5 +177,5 @@
   GROUP BY r.element_id
   ORDER BY ' . $available_order_by[$order_by_index][1] .'
-  LIMIT '.$start.' OFFSET '.$elements_per_page.'
+  LIMIT '.$elements_per_page.' OFFSET '.$start.'
 ;';
 
Index: /trunk/comments.php
===================================================================
--- /trunk/comments.php	(revision 4333)
+++ /trunk/comments.php	(revision 4334)
@@ -327,5 +327,5 @@
 {
   $query.= '
-  LIMIT '.$start.' OFFSET '.$page['items_number'];
+  LIMIT '.$page['items_number'].' OFFSET '.$start;
 }
 $query.= '
Index: /trunk/include/calendar_monthly.class.php
===================================================================
--- /trunk/include/calendar_monthly.class.php	(revision 4333)
+++ /trunk/include/calendar_monthly.class.php	(revision 4334)
@@ -349,5 +349,5 @@
     $query.= '
   ORDER BY RAND()
-  LIMIT 0 OFFSET 1';
+  LIMIT 1';
     unset ( $page['chronology_date'][CDAY] );
 
Index: /trunk/include/category_cats.inc.php
===================================================================
--- /trunk/include/category_cats.inc.php	(revision 4333)
+++ /trunk/include/category_cats.inc.php	(revision 4334)
@@ -106,5 +106,5 @@
     ).'
   ORDER BY RAND()
-  LIMIT 0,1
+  LIMIT 1
 ;';
       $subresult = pwg_query($query);
@@ -134,5 +134,5 @@
     ).'
     ORDER BY RAND()
-    LIMIT 0,1
+    LIMIT 1
   ;';
       $subresult = pwg_query($query);
Index: /trunk/include/functions_notification.inc.php
===================================================================
--- /trunk/include/functions_notification.inc.php	(revision 4333)
+++ /trunk/include/functions_notification.inc.php	(revision 4334)
@@ -445,5 +445,5 @@
   GROUP BY date_available
   ORDER BY date_available DESC
-  LIMIT 0 OFFSET '.$max_dates.'
+  LIMIT '.$max_dates.'
 ;';
   $result = pwg_query($query);
@@ -465,5 +465,5 @@
     AND tn_ext IS NOT NULL
   ORDER BY RAND(NOW())
-  LIMIT 0 OFFSET '.$max_elements.'
+  LIMIT '.$max_elements.'
 ;';
       $dates[$i]['elements'] = array();
@@ -485,5 +485,5 @@
   GROUP BY category_id
   ORDER BY img_count DESC
-  LIMIT 0 OFFSET '.$max_cats.'
+  LIMIT '.$max_cats.'
 ;';
       $dates[$i]['categories'] = array();
Index: /trunk/include/functions_tag.inc.php
===================================================================
--- /trunk/include/functions_tag.inc.php	(revision 4333)
+++ /trunk/include/functions_tag.inc.php	(revision 4334)
@@ -240,5 +240,5 @@
     $query .= '
   ORDER BY counter DESC
-  LIMIT 0,'.$max_tags;
+  LIMIT '.$max_tags;
   }
   else
Index: /trunk/include/section_init.inc.php
===================================================================
--- /trunk/include/section_init.inc.php	(revision 4333)
+++ /trunk/include/section_init.inc.php	(revision 4334)
@@ -491,5 +491,5 @@
     '.$forbidden.'
     '.$conf['order_by'].'
-  LIMIT 0, '.$conf['top_number'].'
+  LIMIT '.$conf['top_number'].'
 ;';
 
@@ -518,5 +518,5 @@
     '.$forbidden.'
     '.$conf['order_by'].'
-  LIMIT 0, '.$conf['top_number'].'
+  LIMIT '.$conf['top_number'].'
 ;';
     $page = array_merge(
Index: /trunk/include/ws_functions.inc.php
===================================================================
--- /trunk/include/ws_functions.inc.php	(revision 4333)
+++ /trunk/include/ws_functions.inc.php	(revision 4334)
@@ -293,5 +293,5 @@
 GROUP BY i.id
 '.$order_by.'
-LIMIT '.(int)($params['per_page']*$params['page']).' OFFSET '.(int)$params['per_page'];
+LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['page']);
 
     $result = pwg_query($query);
@@ -683,6 +683,6 @@
   WHERE '.$where_comments.'
   ORDER BY date
-  LIMIT '.(int)($params['comments_per_page']*$params['comments_page']).
-    ' OFFSET '.(int)$params['comments_per_page'];
+  LIMIT '.(int)$params['comments_per_page'].
+    ' OFFSET '.(int)($params['comments_per_page']*$params['comments_page']);
 
     $result = pwg_query($query);
@@ -1399,5 +1399,5 @@
     AND ', $where_clauses).'
 '.$order_by.'
-LIMIT '.(int)($params['per_page']*$params['page']).' OFFSET '.(int)$params['per_page'];
+LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['page']);
 
     $result = pwg_query($query);
Index: /trunk/random.php
===================================================================
--- /trunk/random.php	(revision 4333)
+++ /trunk/random.php	(revision 4334)
@@ -53,5 +53,5 @@
   ).'
   ORDER BY RAND(NOW())
-  LIMIT 0, '.min(50, $conf['top_number'],$user['nb_image_page']).'
+  LIMIT '.min(50, $conf['top_number'],$user['nb_image_page']).'
 ;';
 
