Fix character encoding mismatch in DB utility function error logging.
Fix syntax error in SQL to purge mediacache entries.