diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index c7572ee9f86..864037e2aef 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -461,7 +461,12 @@ class Categorie { $sql = "SELECT count(c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_association as ca"; - $sql.= " WHERE c.label = '".$label."' AND c.rowid = ca.fk_categorie_fille AND ca.fk_categorie_mere = '".$catmere."'"; + $sql.= " WHERE c.label = '".$label."'"; + if ($catmere) + { + $sql.= " AND c.rowid = ca.fk_categorie_fille"; + $sql.= " AND ca.fk_categorie_mere = '".$catmere."'"; + } $res = $this->db->query ($sql); $res = $this->db->fetch_array ($res); diff --git a/htdocs/categories/create.php b/htdocs/categories/create.php index 498da080ed2..030d784859c 100644 --- a/htdocs/categories/create.php +++ b/htdocs/categories/create.php @@ -139,7 +139,7 @@ print '
".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"
"; $OK = false; } - else if ($c->already_exists($_POST["nom"],$cats_meres)) // on regarde si le nom n'existe pas déjà en tant que catégorie ou sous-catégorie + else if ($c->already_exists($_POST["nom"],$cat_mere)) // on regarde si le nom n'existe pas déjà en tant que catégorie ou sous-catégorie { echo "".$langs->trans ("ErrCatAlreadyExists")."
"; $OK = false;