Fixing bug causing empty categories to be imported

I've encountered a bug (at least on linux based systems) that caused a SQL exception when trying to import non-existent category ids. This simple fix checks if there actually is a category id present in the array before adding it to the SQL query.