Page 1 of 1

' (apostrophe) in SQL challenges...

Posted: 2013-04-19 17:50
by KSan
I am having trouble with text that contains ' in some SQL. Example, O'Brians, Macy's etc. Entering 2 x ' in each place where you normally put in 1 ' solves the problem but I don't want to do that. Has anyone successfully tackled this issue? Thanks much for your advice.

Re: ' (apostrophe) in SQL challenges...

Posted: 2013-04-20 04:33
by KSan
str_replace() which is a php function helped me solve my problem. All good.

Re: ' (apostrophe) in SQL challenges...

Posted: 2019-04-13 18:41
by jmcgov
Hi
I'm having this issue on new version. Apologies in advance if this question is a bit dunce-like!
- the field that I am trying to save is $data['address1']
- the table is address
- I understand the answer is to either strreplace("'",'', $data['address1']) OR $data['address1'] = addslashes($data['address1']), right?

Is this correct? Where do I add the line?
TIA, JAmes

Re: ' (apostrophe) in SQL challenges...

Posted: 2019-04-13 23:43
by jmcgov
Mmh, ignore that :/