diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php
index 8734dd818b313a0dfde808f5ddbe7019411e79af..c1b17f9afec66e9f53a33d336036dab537a130ab 100644
--- a/htdocs/categories/categorie.class.php
+++ b/htdocs/categories/categorie.class.php
@@ -136,8 +136,10 @@ class Categorie
return -1;
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, fk_soc, visible, type) ";
- $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."',".$this->socid.",'".$this->visible."',".$this->type.")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, fk_soc, visible, type) ";
+ $sql.= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."',";
+ $sql.= ($this->socid?$this->socid:"null").",";
+ $sql.= "'".$this->visible."',".$this->type.")";
$res = $this->db->query ($sql);