This topic is locked
[SOLVED]

 oci_parse() error

5/4/2009 10:02:36 AM
PHPRunner General questions
S
scopley author

When trying to insert an apostrophe in the title field of my record I'm receive the following error message:
oci_parse() [function.oci-parse]: ORA-01756: quoted string not properly terminated
Here is the the update query I'm running in the Before record updated event. It tells me the error is on the oci_parse line:
[codebox]//connect to db

$conn=db_connect();
// update the referenced STATUS_CHART record

$strUpdate = "update STATUS_CHART set SC_DIVISION='".$values["SC_DIVISION"]."' , SC_FUNDING_TYPE='".$values["SC_FUNDING_TYPE"]."',SC_TITLE='".$values["SC_TITLE"]."' , SC_POC='".$values["SC_POC"]."' , SC_START_DT='".$values["SC_START_DT"]."' , SC_STATUS='".$values["SC_STATUS"]."' , SC_MOD_DT='".$values["SC_MOD_DT"]."' , SC_COMP_DT='".$values["SC_COMP_DT"]."' , SC_ACT_COMP_DT='".$values["SC_ACT_COMP_DT"]."' , SC_USER_ID='".$values["SC_USER_ID"]."' where SC_FILE_ID_FK='".$oldvalues["AF_FILE_ID_PK"]."'";
$stmtchart = oci_parse($conn, $strUpdate);

oci_execute($stmtchart, OCI_DEFAULT);

oci_commit($conn);
// unset form values to STATUS_CHART

unset($values["SC_DIVISION"]);

unset($values["SC_FUNDING_TYPE"]);

unset($values["SC_TITLE"]);

unset($values["SC_POC"]);

unset($values["SC_START_DT"]);

unset($values["SC_STATUS"]);

unset($values["SC_MOD_DT"]);

unset($values["SC_COMP_DT"]);

unset($values["SC_ACT_COMP_DT"]);

unset($values["SC_USER_ID"]);
// return true if you like to proceed with editing this record

// return false otherwise

return true;

[/codebox]
Any help would be greatly appreciated.
scopley

J
Jane 5/4/2009

Hi,
use add_db_quotes(fieldname,fieldvalue) in your code:

$strUpdate = "update STATUS_CHART set SC_DIVISION=".add_db_quotes("SC_DIVISION",$values["SC_DIVISION"])." , SC_FUNDING_TYPE='".$values["SC_FUNDING_TYPE"]."',SC_TITLE='".$values["SC_TITLE"]."' , SC_POC='".$values["SC_POC"]."' , SC_START_DT='".$values["SC_START_DT"]."' , SC_STATUS='".$values["SC_STATUS"]."' , SC_MOD_DT='".$values["SC_MOD_DT"]."' , SC_COMP_DT='".$values["SC_COMP_DT"]."' , SC_ACT_COMP_DT='".$values["SC_ACT_COMP_DT"]."' , SC_USER_ID='".$values["SC_USER_ID"]."' where SC_FILE_ID_FK='".$oldvalues["AF_FILE_ID_PK"]."'";

S
scopley author 5/4/2009

Jane,
Thank you for your response. Can you tell me what the add_db_quotes does? I'm new at this and I can't seem to find any additional information on this function
scopley

J
Jane 5/5/2009

Hi,
this function add correct quotes to the field values.