escaping data before insertion, query now runs succesfuly