473,320 Members | 2,080 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,320 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 1650
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: 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.