Correct Patient ID field in log.  Use null value not string
log failed queries to php log and provide stack trace in browser error message