Page 1 of 1

Error handling

Posted: Mon Jun 17, 2002 9:36 am
by toppac
I have a question on how to handle errors. I have a function that performs an INSERT sql statement. The statement will give an error if one of the values inserted is not unique. How can I catch that error and then print out a meaningful message to the user. Since it is a Oracle error rather than a PHP error, does OCI have any functions that will help?

Posted: Mon Jun 17, 2002 10:40 am
by Zmodem
Have you looked at Ora_error() and Ora_errorcode() functions in PHP?

Posted: Mon Jun 17, 2002 11:10 am
by toppac
Thanks, now I know how to check for an error. But how do I stop it from automatically outputting an error message. i want to check for an Error which I am doing with OCIError, then if there is an error I'll do a case statement to tell the user what the error is. But the webserver is still outputting this

Code: Select all

Warning: OCIStmtExecute: ORA-00001: unique constraint (REPORT.PK_SKU) violated in D:\Apache\Apache2\htdocs\toppc\confirm.php on line 43
I know what the error code means and why it is doing it. I just need to know how to make it not print out the error for me

Posted: Mon Jun 17, 2002 1:34 pm
by mikeq
Put an @ symbol at the beginning of the function name

i.e. @OCIExecute

The @ suppresses any error messages.

Mike