mysqli: Allow db_query to callback before logging

Allow a callback function to be used to determine if an error should be
logged and an alert mailed
oops: Fixup image stripping (again)