Index: trunk/category.php
===================================================================
--- trunk/category.php	(revision 63)
+++ trunk/category.php	(revision 64)
@@ -234,8 +234,8 @@
   $array_cat_directories = array();
   
-  $query = 'SELECT id,file,date_available,tn_ext,name,filesize';
-  $query.= ',storage_category_id,category_id';
-  $query.= ' FROM '.PREFIX_TABLE.'images';
-  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+  $query = 'SELECT distinct(id),file,date_available,tn_ext,name,filesize';
+  $query.= ',storage_category_id';
+  $query.= ' FROM '.PREFIX_TABLE.'images AS i';
+  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
   $query.= $page['where'];
   $query.= $conf['order_by'];
@@ -252,4 +252,5 @@
   while ( $row = mysql_fetch_array( $result ) )
   {
+    // retrieving the storage dir of the picture
     if ( $array_cat_directories[$row['storage_category_id']] == '' )
     {
Index: trunk/include/functions_category.inc.php
===================================================================
--- trunk/include/functions_category.inc.php	(revision 63)
+++ trunk/include/functions_category.inc.php	(revision 64)
@@ -494,7 +494,7 @@
         $page['title'] = $lang['favorites'];
 
-        $page['where'] = ', '.PREFIX_TABLE.'favorites';
+        $page['where'] = ', '.PREFIX_TABLE.'favorites AS fav';
         $page['where'].= ' WHERE user_id = '.$user['id'];
-        $page['where'].= ' AND image_id = id';
+        $page['where'].= ' AND fav.image_id = id';
       
         $query = 'SELECT COUNT(*) AS nb_total_images';
Index: trunk/picture.php
===================================================================
--- trunk/picture.php	(revision 63)
+++ trunk/picture.php	(revision 64)
@@ -41,7 +41,11 @@
 $query = 'SELECT id,date_available,comment,hit,keywords';
 $query.= ',author,name,file,date_creation,filesize,width,height';
-$query.= ',storage_category_id,category_id';
+$query.= ',storage_category_id';
+if ( is_numeric( $page['cat'] ) )
+{
+  $query.= ',category_id';
+}
 $query.= ' FROM '.PREFIX_TABLE.'images';
-$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id = ic.image_id';
 $query.= $page['where'];
 $query.= ' AND id = '.$_GET['image_id'];
@@ -65,7 +69,7 @@
 $page['storage_category_id'] = $row['storage_category_id'];
 // retrieving the number of the picture in its category (in order)
-$query = 'SELECT id';
+$query = 'SELECT DISTINCT(id)';
 $query.= ' FROM '.PREFIX_TABLE.'images';
-$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id = ic.image_id';
 $query.= $page['where'];
 $query.= $conf['order_by'];
@@ -129,5 +133,6 @@
     $query = 'SELECT id';
     $query.= ' FROM '.PREFIX_TABLE.'images';
-    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+    $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category  AS ic';
+    $query.= ' ON id = ic.image_id';
     $query.= $page['where'];
     $query.= $conf['order_by'];
@@ -212,7 +217,7 @@
 {
   $prev = $page['num'] - 1;
-  $query = 'SELECT id,name,file,tn_ext,storage_category_id';
+  $query = 'SELECT DISTINCT(id),name,file,tn_ext,storage_category_id';
   $query.= ' FROM '.PREFIX_TABLE.'images';
-  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
   $query.= $page['where'];
   $query.= $conf['order_by'];
@@ -458,5 +463,5 @@
 }
 //------------------------------------ admin link for information modifications
-if ( $user['status'] == "admin" and is_numeric( $page['cat'] ) )
+if ( $user['status'] == 'admin' )
 {
   $vtp->addSession( $handle, 'modification' );
@@ -470,7 +475,7 @@
 {
   $next = $page['num'] + 1;
-  $query = 'SELECT id,name,file,tn_ext,storage_category_id';
+  $query = 'SELECT DISTINCT(id),name,file,tn_ext,storage_category_id';
   $query.= ' FROM '.PREFIX_TABLE.'images';
-  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+  $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
   $query.= $page['where'];
   $query.= $conf['order_by'];
