473,231 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Trap server error (e.g. 404) with php

Hi,

Is it possible to trap a (web)server error (e.g. 404) with php.
I have one custom error page (php) for all the server errors.
So i want to know with error number occurs.

Regards,

Robertcio
Jul 17 '05 #1
7 1648
My english is not that good, but hope i understood you.

If you have an errorpage for all errors, you already know .htaccess files,
yeah?

In your .htaccess file you can refere an errorpage by doing this:

ErrorDocument 404 error.php?code=404
Jul 17 '05 #2
> My english is not that good, but hope i understood you.
Me either :-))
If you have an errorpage for all errors, you already know .htaccess files,
yeah? I use my httpd.conf file.
In your .htaccess file you can refere an errorpage by doing this:
ErrorDocument 404 error.php?code=404

How can i trap this in my php page ? (i'am new to php)

Robertico

Jul 17 '05 #3
> How can i trap this in my php page ? (i'am new to php)

Ahh thats the point!
You can catch the variable by doing this:

<?php
switch ($_GET["code"]){
case 404:
echo "Page not founded";
break;
case 403:
echo "Forbidden";
break;
case 500:
echo "Servererror";
break;
default:
echo "An unknown error occoured";
}
?>
Jul 17 '05 #4
Thx, works fine.

Where can i found more information about this ? (this specific item)

Robertico
Jul 17 '05 #5
Thx.
Great resource.

Robertico
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: rcb845 | last post by:
HI fellow php fans, I am blocked with a simple problem, at least it seems simple, but I cannot make it through. I want to execute a .php script in case of "error 404, page not found". I am...
4
by: Bill | last post by:
I want to add a favicon.ico to one of my websites. Because this is a large site, with two domains sharing an IP, I want to be able to redirect the favicon .ICO file from my VBScript Error 404 file...
3
by: Samuel | last post by:
I set up a custom error 404 page as URL and it works sometimes but not always. The problem is when the URL contains special characters, like [ or : , it produces the error message: The system...
0
by: Pai | last post by:
Hello there, every time I try to create a project using Visual Interdev 2003, I get the following error: The default web access mode for this project is set to file share, but the project...
0
by: Pai | last post by:
Hello there, every time I try to create a project using Visual Interdev 2003, I get the following error: The default web access mode for this project is set to file share, but the project...
3
by: SMG | last post by:
Hi All, From where I can customize 404 error. I.e. the error is printed below.. Server Error in '/sharekhan' Application. The resource cannot be found. Description: HTTP 404. The...
0
by: cider123 | last post by:
This is just information to maybe help others with the problem I ran across the other day. I had a Remote Object working just fine on a 2003 Server. I wanted to try it on another 2003 Server,...
3
by: ton | last post by:
Hi, I've developed some webcontrols in VB, I'm using these in a website project If the webcontrol is getting an error I ll get the message: Server error in '/' application, and than more...
2
by: Edward | last post by:
I have a need to detect if an error is caused by HTTP error 404 in Application_Error (in global.asax). I read MSDN docs but did not get an answer. Is there a reliable workaround to detect this...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.