Log error when a query fails in MySQL DB
Closes T79