fix two queries and corrected escaping of ticket-category, thx to vali

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>