I asked this question over at phpbuilder.com and haven't gotten an answer. So I'm thinking it might require someone more knowledgeable about Oracle, so I'm posting it here.
In my code below I'm having trouble getting oci_error to give me an error message.
Code:
$SQL = "INSERT INTO TABLE(FIELD1, FIELD2, FIELD3, FIELD4, FIELD5) VALUES (:f1, '0', :f3, sysdate, 'webuser')";
$stmt = oci_parse($GLOBALS["DB"]->conn, $SQL); // DB is a class which handles all the database connections. In other parts of the code it works, so I haven't included it all in this example.
oci_bind_by_name($stmt, ":f1", $CASE_NUMBER); // These vars have values assigned earlier and are just strings.
oci_bind_by_name($stmt, ":f3", $CASE_SECTION);
oci_execute($stmt, OCI_DEFAULT); // OCI_NO_AUTO_COMMIT this needs to be a transaction
if (oci_num_rows($stmt) != 1) {
$error = 1;
$error_msg .= "<hr><font color=red size=\"+2\">ERROR WITH INSERT INTO TABLE!! SQL:</font><P>$SQL</P>";
$e = oci_error($stmt);
$error_msg .= "<P>E-MESSAGE:" . htmlentities($e['message']) . "</P><hr>";
// print_r($e)
}
if ($error != 0) {
print $error_msg;
}
Now I forgot to grant my phpuser permission to insert into TABLE. So it bombs out with the following
Quote:
Warning: oci_execute() [function.oci-execute]: ORA-00942: table or view does not exist ....
However when it goes to print out the error message there is no message. If I uncomment the print_r line, it acts like $e is null.
I tried changing $e to be oci_error($stmt) instead of the database link and still nothing.
While developing this I've had other oracle errors and oci_error has given me the text of the error message with no problems. It only seems to be this one where the table of view does not exist where it won't oci_error won't tell me.
This is a problem since when I go to production, warnings aren't displayed to the user and I'll have to write $e or oci_error to a log file.
Am I doing something wrong? How do I fix this?
Thanks in advance.