So here's my code:

$SQL = "INSERT INTO TABLE(FIELD1, FIELD2, FIELD3, FIELD4, FIELD5) VALUES (:f1, '0', :f3, sysdate, 'webuser')";

$stmt = oci_parse($GLOBALS["DB"]->conn, $SQL);

oci_bind_by_name($stmt, ":f1", $CASE_NUMBER);
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

Warning: oci_execute() [function.oci-execute]: ORA-00942: table or view does not exist in /home/lth2h/public_html/mytest.php on line 8

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?

    Write a Reply...