Re: Oracle problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Perhaps it would be easier to use bind variables instead. For example,

$empno = 1234;
$ename = "O'Reilly";

$conn = OCILogon('scott', 'tiger');
$sql = 'INSERT INTO emp (empno, ename) VALUES (:empno, :ename)';
$stmt = OCIParse($conn, $sql);
OCIBindByName(':empno', $empno, -1);
OCIBindByName(':ename', $ename, -1);
OCIExecute($stmt);

Check out Thies' presentation:
http://conf.php.net/pres/index.php?p=slides%2Foci&id=oci2

If you have questions, let us know.

-Anthony

> From: "Ford, Mike               [LSS]" <M.Ford@lmu.ac.uk>
> Date: Wed, 16 Oct 2002 12:14:58 +0100
> To: "'N.A.Morgan@bton.ac.uk'" <N.A.Morgan@bton.ac.uk>,  php-db@lists.php.net
> Subject: RE:  Oracle problem
> 
>> -----Original Message-----
>> From: N.A.Morgan@bton.ac.uk [mailto:N.A.Morgan@bton.ac.uk]
>> Sent: 16 October 2002 08:51
>> To: php-db@lists.php.net
>> 
>> Has anyone out there using PHP and Oracle come across this
>> problem?  I have
>> a text area that allows free-form text that I store in a
>> varchar2 column.  I
>> have problems with apostrophes in the free-form text.
> 
> Uh-oh!  Standard can of worms no. 3!
> 
>> When 
>> users put in an
>> apostrophe the SQL fails.  If I force 3 apostrophes (the
> 
> Shouldn't that be *two* apostrophes?  That's how it works here, anyway!
> 
>> usual Oracle method
>> of embedding apostrophes) the SQL fails.  The only way to get
>> round the
>> problem is to strip them out (which I consider a work-around
>> not a fix).
> 
> You may also want to investigate the php.ini settings magic_quotes_gpc,
> magic_quotes_runtime and magic_quotes_sybase -- although personally I prefer
> not to use these as I'm averse to magic (well, other people's, anyway!).
> 
> 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
> 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux