Keep all the DECLARE statements as the first statements in your code:
Also what happens if the SELECT statements do not return any value. You should include some kind of handler in there
DECLARE CONTINUE HANDLER FOR NOT FOUND SET ....
Code:
DROP TRIGGER IF EXISTS `forum_course_create`;
DELIMITER //
CREATE TRIGGER `forum_course_create` BEFORE INSERT ON `course`
FOR EACH ROW BEGIN
DECLARE x VARCHAR(50);
DECLARE y INTEGER
SET x = (select cat_name from category where cat_id = NEW.cat_id);
SET y = (select id from forum_category where category_name = x);
insert into forum_category (category_name,category_desc,parent_category) values (NEW.course_name,NEW.course_description,y);
END IF
END
//
DELIMITER ;