Can't sort table based on sql query

@Kabirdas sorry, I should clarify. Prepared statements are being used, not disabled. Should I disable prepared statements to resolve this?