log failed queries to php log and provide stack trace in browser error message