{'leaf'} == true){ $leaf = 1; } else{ $leaf = 0; } if($obj->{'parentId'} == null){ $parentID = 'NULL'; } else{ $parentID = $obj->{'parentId'}; } if($obj->{'Duration'} == ''){ $duration = 0; } else{ $duration = $obj->{'Duration'}; } $q = 'INSERT INTO tasks (Name, StartDate, EndDate, leaf, Duration, DurationUnit, PercentDone, Cls, parentId, PhantomId, PhantomParentId) VALUES ("'.$obj->{'Name'}.'", "'.$obj->{'StartDate'}.'", "'.$obj->{'EndDate'}.'", "'.$leaf.'", "'.$duration.'", "'.$obj->{'DurationUnit'}.'", "'.$obj->{'PercentDone'}.'", "'.$obj->{'Cls'}.'", '.$parentID.', "'.$obj->{'PhantomId'}.'", "'.$obj->{'PhantomParentId'}.'")'; $r = mysql_query($q); if(!$r){ echo '{"success": false, "error": "'.db_error($q).'"}'; } $obj->{'Id'} = mysql_insert_id(); } echo json_encode($array);