Fix issues with database queries

It was missing single quotes around the search terms, which wouldn't
have worked for the string searches.