|
-
Aug 1st, 2002, 07:50 PM
#1
Thread Starter
Stuck in the 80s
Error Trapping
Is there a way to trap errors and do certain things based on what error is received?
Say, if I get a "Function not defined error" can I, instead of it displaying the error message, have it go to a main function?
-
Aug 1st, 2002, 09:29 PM
#2
Fanatic Member
I did this on one of my recent projects (this works well with sql statements, and I think you can use it for other functions too:
PHP Code:
function ErrorHandling($type,$message) {
echo "Type: $type<br />Message: $message";
}
$query = mysql_query("select * from table") or die(ErrorHandling("MySQL Query",mysql_error());
-
Aug 1st, 2002, 11:08 PM
#3
Thread Starter
Stuck in the 80s
Great idea! But why doesn't this work?:
PHP Code:
eval($_REQUEST["action"] . "();") or die(eval_error());
It prints the normal thing and prints the eval_error() function.
-
Aug 2nd, 2002, 05:28 AM
#4
Fanatic Member
From php.net
A return statement will terminate the evaluation of the string immediately. In PHP 4, eval() returns FALSE unless return() is called in the evaluated code, in which case the value passed to return() is returned. In PHP 3, eval() does not return a value.
That is why.
-
Aug 2nd, 2002, 11:03 AM
#5
Thread Starter
Stuck in the 80s
I think what I'm doing is bad anyways, so I ditched the idea.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|