TIL: Apostrophe in MySQL data

It took a long time for me to discover why one particular update/insert in a MySQL database failed while most updates worked OK.  And the failed transactions did not throw an error – they came back via the ‘success’ path.

Turns out any single quotes in MySQL string data cause this behavior.  Once I escaped it like this \’ everything went well.  And a read returns just the apostrophe without a backslash. Oh, and WordPress (or this theme) insists on showing the above as a “smart” apostrophe, even if I key it in as '

As far as I’ve found so far, the only other character that needs escaping is \ itself (i.e. as \\) which is obvious or \’ wouldn’t work.


Sorry, the comment form is closed at this time.

A personal blog about a few of my interests … other than Visual Thinking