...

View Full Version : Error Reporting



Dalziel
04-12-2004, 03:28 PM
In my error pages for my site I've added some code to send me an E-mail with the HTTP_REFERRER if it is set. It's pretty simple but it more or less does the job for me. This is it:



<?php
$domain = $_SERVER["HTTP_REFERER"];
if (isset($domain))
{
if (!empty($domain))
{
mail("joe@example.com", "Error 404", "A 404 came from $domain", "From: error@myserver.com");
}
}
?>


Is there any way I could detect the page they were trying to access?

E.g. "A 404 came from [HTTP_REFERRER] linking to [URL OF MISSING PAGE]" that would just save me going through the whole page trying to figure out what is causing the error. I got 4 messages all dated the same today giving 404s from my homepage and I can't find any broken links :mad:

Knowing what they were trying to access would make it a lot easier to identify the problem.

Nightfire
04-12-2004, 04:35 PM
You could use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME']

hehe a post I got a chance to answer instead of raf :D

bcarl314
04-12-2004, 04:59 PM
You may also want $_SERVER['QUERY_STRING']

raf
04-12-2004, 05:13 PM
You could use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME']

hehe a post I got a chance to answer instead of raf :D

Already made a formal complaint to my ISP for the downtime today... :D
Back OT --> can't you just check your webservers logfile. This will give you all the info you need + there are a lott of logfile anaylising tools to transform these logs into the form you need them

Dalziel
04-12-2004, 06:26 PM
I use a web host and all I get is webalizer details and it doesn't really tell me enough. I don't know much about that. There is a directory in my hosting account called statistics but I get permission denied trying to open it. :confused: :confused: :confused: :confused: :confused:

Surely using PHP_SELF would not work. The E-mail could be "A 404 came from [HTTP_REFERRER] linking to [URL OF MISSING PAGE]" but surely if I used PHP_SELF the URL of missing page would come through as 404.php :confused: :confused: no??? :confused: :confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum