Error Page, How can i make one

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Error Page, How can i make one

Post by tecktalkcm0391 »

Is this possible:

A user is browsing my site, and then they come to a page that has errors on it, PHP see's that there is errors and then redirects them to another page that says we are expecing errors please try again later.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What kind of errors are you talking about?

Mac
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Any error but mostly just MySQL Errors
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Yes, it is possible. What kind of help do you need then?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

What I want is that when an error message, no matter what it is, comes up, it fowards the User to "error.php"

On error.php all it says is: Sorry but an error has occured. Please try again later.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

$query = "SELECT * FROM users";

if(!$query) {
$error=mysql_error();
include_once("error.php");

// or you could use
echo '<meta http-equiv="refresh" content="0;URL=error.php" />';
exit();
}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Are you referring to PHP script errors? Like "call to undefined function foo() on line 26" ?

In PHP5 exception handling can do that for you.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I only have PHP Version 4.4.1 and i can update because I have my website hosted by someone else.

Any way in PHP Version 4.4.1?

I didn't really get the expection handling anyway.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

set_error_handler() is your friend ;)
Post Reply