SQL: Where is mistake?
Please help me finding where I have made mistake?

    delimiter //
    CREATE FUNCTION `count_photos_in_gallery`(`tmp_gallery_id` INT(11) NOT NULL) RETURNS TINYINT(3) UNSIGNED
    BEGIN
    	DECLARE `tmp_count` TINYINT(3) UNSIGNED DEFAULT 0;
    
    	SELECT COUNT(`id`) INTO `tmp_count` FROM `photos_items` WHERE `gallery_id`=`tmp_gallery_id` LIMIT 1;
    	
    	RETURN `tmp_count`;
    END//
SQL: Where is mistake?
===

Please help me finding where I have made mistake?

    delimiter //
    CREATE FUNCTION `count_photos_in_gallery`(`tmp_gallery_id` INT(11) NOT NULL) RETURNS TINYINT(3) UNSIGNED
    BEGIN
    	DECLARE `tmp_count` TINYINT(3) UNSIGNED DEFAULT 0;
    
    	SELECT COUNT(`id`) INTO `tmp_count` FROM `photos_items` WHERE `gallery_id`=`tmp_gallery_id` LIMIT 1;
    	
    	RETURN `tmp_count`;
    END//