At a first glance - one of the $catids has an underscore which needs removing.
Unfortunately don't have time to test it just at the moment.
Edit - make that two of the $cat_ids!
Unfortunately don't have time to test it just at the moment.
Edit - make that two of the $cat_ids!