jettero's solution will fix you right up. You are doing a straight string substitution in your SQL, which is bad. Using prepare() and binding your column values will magically take care of things like escaping that pesky single quote in the record being skipped.