Fixed bug: database query error messages were empty after preparing query. Statements must be stored in local variable for error messages to be stored.