Update SQL patch to log the HTTP Referer only if it available
Escape SQL single quotes with two single quotes