fix quoting in mysql

the old mechanism did not consider undefined values NULL, and failed
for empty strings and for stuff that looked vaguely like numbers, but were
not well-formed numbers