0

My sql is:

SELECT DISTINCT fs_region FROM ats_sample WHERE company_id >= 1  AND 
country='COTE D'IVOIRE'  ORDER BY fs_region

because of (') in between the character COTE D'IVOIRE query is getting closed there itself and oracle throws an error like

ORA-00933: SQL command not properly ended

how to parse data in sql/oracle query in PHP?? Need Help Thank you..

Jigar Shah
  • 6,143
  • 2
  • 28
  • 41
Surya
  • 35
  • 11
  • 1
    Just double up the quote in `COTE D'IVOIRE`, e.g. use `'COTE D''IVOIRE'` – Tim Biegeleisen Sep 08 '17 at 06:15
  • Use a parameterized query. You should do this for reasons other than just 'difficulty in using strings that contain apostrophes' See http://bobby-tables.com for reasons and further examples applicable to php – Caius Jard Sep 08 '17 at 06:16
  • @TimBiegeleisen yes, but that's likely just a band-aid if this query is being run from a front end language, lets recommend the start of doing it properly instead, lest he get into the habit of thinking it's ok to just string replace apostrophe with double apostrophe as a matter of course when doing queries.. – Caius Jard Sep 08 '17 at 06:19
  • @CaiusJard Actually, if the OP is using _any_ quotes whatsoever I would say that it either means no parameterized query or using it wrongly. The whole point is that the app languge handles the escaping on your behalf. – Tim Biegeleisen Sep 08 '17 at 06:20
  • Hear here! Sadly, people only come to SO to get a fix for their broken, poor solution, not to be educated about a good solution.. but I'll always try! – Caius Jard Sep 08 '17 at 06:29

0 Answers0