Fixed sql query.
Fixed surrogateescape error.