From 7553e0473e42d2c6bf62dca67a647d0b738f2fba Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Tue, 7 Oct 2008 20:07:28 +0000
Subject: [PATCH] Fix: Failed to create

---
 htdocs/categories/categorie.class.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php
index 8734dd818b3..c1b17f9afec 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);
-- 
GitLab