RE: [PHP] Adding a variable to oracle that contains quotation mar ks??

From: Date: Tue, 21 Jan 2003 16:05:04 +0000
Subject: RE: [PHP] Adding a variable to oracle that contains quotation mar ks??
Groups: php.general 
Request: Send a blank email to php-general+get-132443@lists.php.net to get a copy of this message
> -----Original Message----- > From: Rea_David@emc.com [mailto:Rea_David@emc.com] > Sent: 21 January 2003 15:05 > > Thanks Rick & Henry, but I am still unable to add single > quotation marks '. > When I added the \' to the variable as given below (thanks > again Rick) I get > the following error when trying to add anything, regardless of ': Oracle does its quote-escaping different! To insert a single-quote within a single-quoted value, you have to double it, so: $query = "UPDATE ACTIVITY SET COMMENTS = 'That''s right' WHERE ..."; So, you either have to run a str_replace("'", "''", $updatecomments) before constructing the query, or you can use addslashes() and turn on the magic_quotes_sybase option -- if you do the latter, and also have magic_quotes_gpc and/or magic_quotes_runtime turned on, "magic" quoting will also escape with a second quote rather than a backslash. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#132443) next »