Help: stringing text together or stored procedure call

So i hope this posts correctly (1st time posting). I have a form and am trying to post to an Oracle 11g db using a stored procedure. I can:

  1. echo the data submitted to the form via POST
  2. insert data directly into the database from sqlplus
    a. typing following into sqlplus:
    SQL> call InsertCustomerAndInterests ('bond','james','007','000-0000','[email protected]','england');

so the individual components work, but I am having a problem (I think) with how I am stringing the text together from within the insertUser.php script (below). I have been at this a long time and would love to see this insert into the database. It is possible i am calling the stored procedure incorrectly. not sure where the problem lies. reading other posts, i know this is subject to sql injection and has no error checking on the php side … i don’t care (yet). i just want it to work.

[php]

<?php /* Set Variables */ $lname=$_POST["lname"]; $fname=$_POST["fname"]; $area_code=$_POST["area_code"]; $phone=$_POST["phone"]; $email=$_POST["email"]; $nationality=$_POST["nationality"]; /* Connect to the Oracle DB */ $connection = ocilogon("uname","password","host.domain.com"); #this does work //$connection = ocilogon("[email protected]/password"); #doesn't work if (!$connection) { echo "Couldn't make a connection."; exit; } else { echo "Connected! (Oracle Database)

"; } /* Define SQL */ //FROM SQLPLUS PROMPT: //call InsertCustomerAndInterests ('bond','james','007','000-0000','[email protected]','england'); /* try1 */ //$sql = "CALL InsertCustomerAndInterests(' .$lname . ',' .$fname . ',' .$area_code . ',' .$phone . ',' .$email . ',' .$nationality . ')"; /* try2 */ //$sql = "CALL InsertCustomerAndInterests(' .$lname .',' .$fname .',' .$area_code .',' .$phone .',' .$email .',' .$nationality .')"; /* Kinda Works */ $sql = "CALL InsertCustomerAndInterests(' .$lname . ',' .$fname . ',' .$area_code . ',' .$phone . ',' .$email . ',' .$nationality .')"; /* Peek into data */ echo $lname . ' ' .$fname . ' ' .$area_code . ' ' .$phone . ' ' .$email . ' ' .$nationality; $stmt = oci_parse($connection,$sql); oci_close($connection); ?>

[/php]

I got it. sometimes a break from staring at a monitor will help. the (pre-existing) columns were defined wrong in the DDL. for example, the AREA_CODE column was defined as CHAR(3) instead of NUMERIC(3) and no constraints existed. I changed the datatype, added some constraints, and all is well now.

I gained bits of info from others’ postings that helped me identify.

Thanks all.

Sponsor our Newsletter | Privacy Policy | Terms of Service