Errors declaring variables in stored procedure?
DECLARE is permitted only inside a BEGIN ... END compound statement
  and must be at its start, before any other statements. Declarations
  must follow a certain order. Cursor declarations must appear before
  handler declarations. Variable and condition declarations must appear
  before cursor or handler declarations.


Try this :

DELIMITER $$
DROP PROCEDURE IF EXISTS `do_thing` $$
CREATE PROCEDURE `do_thing`()
BEGIN
       -- DECLARE STATEMENTS first
        DECLARE how_many INT;
        DECLARE `_rollback` BOOL DEFAULT 0;
        DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET `_rollback` = 1;
        --
        SELECT COUNT(*) INTO how_many FROM things;       

        -- Start transaction.
        START TRANSACTION;
                -- Do all the things.
        IF `_rollback` THEN
                ROLLBACK;
        ELSE
                COMMIT;
        END IF; 
END $$
DELIMITER ;