NYCPHP Meetup

NYPHP.org

[nycphp-talk] oci8 bind error

Hans Zaunere lists at zaunere.com
Wed Jul 1 13:10:36 EDT 2009


Hi,

Hmm, strange - I've googled around and this is a pretty common error where
the resolution is generally some subtle way the variables are defined and
bound.  I can't spot the problem, but play around with the query, perhaps
some lowercase stuff, etc., and flags to the oci_bind_by_name() call.

H


> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-
> bounces at lists.nyphp.org] On Behalf Of Eric Gewirtz
> Sent: Wednesday, July 01, 2009 11:59 AM
> To: 'NYPHP Talk'
> Subject: Re: [nycphp-talk] oci8 bind error
> 
> Hi Hans,
> 
> Thks for the reply.
> 
> I have double checked and the table I am testing with (KB_TEST) has one
> field and it is VARCHAR(25). I believe the oci_parse() is working since
> I'm
> not "dieing" with an error message and the code gets to the
> oci_bind_by_name().
> 
> 
> To your point that this "oci_bind_by_name ($stmt, ":TESTNAME",
> "ERIC");"
> should work - I do not get the oracle error when run this statment, I
> get a
> PHP fatal error: Only variables can be passed by reference. This makes
> no
> sense to me either. I get the oracle error when I run;
> $val = 'ERIC';
> $bindVar = ':TESTNAME';
> oci_bind_by_name ($stmt, $bindVar, $val)
> 
> So I just added some primitive type checking on the variables I'm
> passing to
> the bind and confirmed that $stmt is a resource, $val and $bindVar are
> strings.
> 
> I'm using is_string() and is_resource().
> 
> As to the ditching the "$insSQL = strtoupper($insSQL);"; I only added
> it
> because I was running out of ideas and I know ORACLE like to work with
> upper
> case (you can use mixed case but it is not fun).
> 
> Eric
> 
> 
> 
> SolutionOne
> Eric Gewirtz
> 162 Turk Hill Road
> Brewster NY, 10509
> Phone: 845-729-7800
> FAX:    845-279-5502
> 
> 
> >-----Original Message-----
> >From: talk-bounces at lists.nyphp.org [mailto:talk-
> bounces at lists.nyphp.org] On
> >Behalf Of Hans Zaunere
> >Sent: Wednesday, July 01, 2009 11:04 AM
> >To: 'NYPHP Talk'
> >Subject: Re: [nycphp-talk] oci8 bind error
> >
> >Hello,
> >
> >> Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number
> in
> >> /appl/wideacc/CustMast/in/OCIpreptest.php on line 23
> >
> >
> >> Below is the test code I'm running;
> >>
> >>
> >> //Connect to the Database
> >> $dbUser  = 'c1';
> >> $dbPSWD  = p1';
> >> $db = 'db1';
> >> $con = oci_connect($dbUser, $dbPSWD, $db);
> >> if (!$con) die ('Connect to DB failed');
> >> //$insSQL = 'INSERT INTO KB_TEST (TESTNAME) VALUES (:TESTNAME)';
> >> $insSQL = "INSERT INTO KB_TEST  VALUES (:TESTNAME)";
> >> $insSQL = strtoupper($insSQL); // upper case since ORACLE prefers
> upper
> >
> >I'd ditch this...
> >
> >> and we know we do not have a case issue
> >> echo "SQL is $insSQL \n";
> >> $stmt = oci_parse($con, $insSql);
> >> if (!$stmt) die ('Parse for insert failed');
> >>
> >> //oci_bind_by_name ($stmt, ":TESTNAME", "ERIC");
> >
> >This one seems as though it should work - are you sure the oci_parse()
> is
> >successful and that the first column in that table is really a
> varchar?
> >
> >H
> >
> >
> >_______________________________________________
> >New York PHP User Group Community Talk Mailing List
> >http://lists.nyphp.org/mailman/listinfo/talk
> >
> >http://www.nyphp.org/show_participation.php
> 
> 
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list