PhP Script Problem

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Mon Jul 26, 2004 9:36 am    Post subject: PhP Script Problem Reply with quote

i am working on a php code & it gets & Error
can some one help me out the code is

Code:
 <?php

//Find error code
$error=$_GET['error'];

//E-mail to be used for errors (Change this to your email address)
$email = "error@example.com";

//Find reffering and requested URLs
$referring_url = $_SERVER['HTTP_REFERER'];
$requested_url = $_SERVER["REQUEST_URI"];

//Different error messages to display
switch ($_REQUEST['error']) {

//Error 400 - Bad Request
case 400:
$errorname = 'Error 400 - Bad Request';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Bad Request</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
   Error 400<BR>
        <BR>
        The URL that you requested, was a bad request. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.</FONT>';
   break;


//Error 401 - Authorization Required
case 401:
$errorname = 'Error 401 - Authorization Required';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Authorization
        Required</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
        Error 401<BR>
        <BR>
        The URL that you requested, requires preauthorization to access.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 403 - Access Forbidden
case 403:
$errorname = 'Error 403 - Access Forbidden';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Access
        Forbidden</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
        Error 403<BR>
        <BR>
        Access to the URL that you requested, is forbidden.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 404 - Page Not Found
case 404:
$errorname = 'Error 404 - Page Not Found';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">File Not
        Found</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>Error 404<BR>
        <BR>
        We're sorry but the page you are looking for cannot be found.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 500 - Server Configuration Error
case 500:
$errorname = 'Error 500 - Server Configuration Error';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Server
        Configuration Error</FONT></B><FONT size="2" face="Verdana, Arial, Helvetica, sans-serif"><BR>
        Error 500<BR>
        <BR>
        The URL that you requested, resulted in a server configuration error.
        It is possible that the condition causing the problem will be gone by
        the time you finish reading this. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Unknown error
default:
$errorname = 'Unknown Error';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Unknown Error</FONT></B><FONT size="2" face="Verdana, Arial, Helvetica, sans-serif"><BR>
        The URL that you requested, resulted in an unknown error.
        It is possible that the condition causing the problem will be gone by
        the time you finish reading this. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';

}

//Display selected error message
echo($errordesc);

//E-mail error to your e-mail address (If you do not wish to receive emails delete the following paragraph)
$datetime = date("l dS of F Y H:i:s");
$message = "<i>The following error has been received on "."$datetime\n</i><br>\n<br>\n";
$message .= "<b><i>$errorname</i></b><br>\n";
$message .= "<i>Requested URL:</i> " . $requested_url . "\n<br><i>Referring URL:</i> " . $referring_url;
$to = "$email";
$subject = "Web Site Error";
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to,$subject,$message,$headers);
//End of E-mail sender

?></form>
thanks
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Mon Jul 26, 2004 8:16 pm    Post subject: Reply with quote

You are receiving an error? That's either pretty ironic, or a good thing. What error are you getting?

First, maybe I'm wrong, but I believe "$_GET['error']" is to retrieve data from a query string. Make sure you're using it properly.

Second, use $_SERVER['REQUEST_URI'] instead of $_SERVER["REQUEST_URI"].

Third, is this on a UNIX or Windows system? If it is Windows, you need to use \r\n instead of \n.
_________________
Bienvenidos!
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Tue Jul 27, 2004 12:53 am    Post subject: Re: PhP Script Problem Reply with quote

Override,

You should change:

Code:
$error=$_GET['error'];


with:

Code:
$error=$_SERVER['REDIRECT_STATUS']


You should also change your PHP configuration in Abyss as follows (to be able to get the right value of REDIRECT_STATUS in your script:

* In CGI Parameters, delete the CGI Custom Environment variable REDIRECT_STATUS .
* Open php.ini, and add the following line:

Code:
cgi.force_redirect = 1


Save the file and retry your script (assuming that you have configured it as the default custom error page in Abyss.)
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Tue Jul 27, 2004 4:18 am    Post subject: Reply with quote

Code:
 <?php

//Find error code
$error=$_SERVER['REDIRECT_STATUS'][1];

//E-mail to be used for errors (Change this to your email address)
$email= 'error@example.com';

//Find reffering and requested URLs
$referring_url = $_SERVER['HTTP_REFERER'][2];
$requested_url = $_SERVER['REQUEST_URI'][3];

//Different error messages to display
switch ($_REQUEST['REDIRECT_STATUS']) {

//Error 400 - Bad Request
case 400:
$errorname = 'Error 400 - Bad Request';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Bad Request</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
   Error 400<BR>
        <BR>
        The URL that you requested, was a bad request. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.</FONT>';
   break;


//Error 401 - Authorization Required
case 401:
$errorname = 'Error 401 - Authorization Required';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Authorization
        Required</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
        Error 401<BR>
        <BR>
        The URL that you requested, requires preauthorization to access.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 403 - Access Forbidden
case 403:
$errorname = 'Error 403 - Access Forbidden';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Access
        Forbidden</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>
        Error 403<BR>
        <BR>
        Access to the URL that you requested, is forbidden.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 404 - Page Not Found
case 404:
$errorname = 'Error 404 - Page Not Found';   
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">File Not
        Found</FONT></B><FONT face="Verdana, Arial, Helvetica, sans-serif" size="2"><BR>Error 404<BR>
        <BR>
        We are sorry but the page you are looking for cannot be found.<BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Error 500 - Server Configuration Error
case 500:
$errorname = 'Error 500 - Server Configuration Error';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Server
        Configuration Error</FONT></B><FONT size="2" face="Verdana, Arial, Helvetica, sans-serif"><BR>
        Error 500<BR>
        <BR>
        The URL that you requested, resulted in a server configuration error.
        It is possible that the condition causing the problem will be gone by
        the time you finish reading this. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';
   break;


//Unknown error
default:
$errorname = 'Unknown Error';
$errordesc = '<B><FONT size="5" face="Verdana, Arial, Helvetica, sans-serif">Unknown Error</FONT></B><FONT size="2" face="Verdana, Arial, Helvetica, sans-serif"><BR>
        The URL that you requested, resulted in an unknown error.
        It is possible that the condition causing the problem will be gone by
        the time you finish reading this. <BR>
        <BR>
        If this problem persists please report it by sending an e-mail to <A href="mailto:'."$email".'">'."$email".'</A>,
        mentioning the error message received and the page you were trying to
        reach. We are sorry for any inconvenience caused and we will do all we
        can to fix the error as soon as possible.<BR>
        </FONT>';

}

//Display selected error message
echo($errordesc);

//E-mail error to your e-mail address (If you do not wish to receive emails delete the following paragraph)
$datetime = date("l dS of F Y H:i:s");
$message = "<i>The following error has been received on "."$datetime\n</i><br>\n<br>\r\n";
$message .= "<b><i>$errorname</i></b><br>\r\n";
$message .= "<i>Requested URL:</i> " . $requested_url . "\r\n<br><i>Referring URL:</i> " . $referring_url;
$to = "$email";
$subject = "Web Site Error";
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to,$subject,$message,$headers);
//End of E-mail sender

?></form>


now it is giveing me this Error

Code:
Notice: Undefined index: REDIRECT_STATUS in D:\Abyss Web Server\htdocs\Error\error.php on line 4

Notice: Undefined index: HTTP_REFERER in D:\Abyss Web Server\htdocs\Error\error.php on line 10

Notice: Undefined index: REDIRECT_STATUS in D:\Abyss Web Server\htdocs\Error\error.php on line 14
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Jul 27, 2004 2:07 pm    Post subject: Reply with quote

I guess nobody knows how to configure their php.ini file , thats very sad.
Open php.ini in C:\Windows or C:\Winnt depending on your OS and find
display_errors=On and change it to Off , see how easy that was , later!
Back to top View user's profile Send private message Visit poster's website
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Wed Jul 28, 2004 7:09 am    Post subject: Reply with quote

that worked ty

but i ant geting the taged Error message like Error 400 - Bad Request

instad i am geting Unknown error tag in the script

so what do i need to do to make it work any help would be a appericated thanks
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu Jul 29, 2004 12:26 am    Post subject: Reply with quote

Override,

It depends on how you're calling this script. It should be called by Abyss as a custom error page. If you browse it directly do not expect any interesting result.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Thu Jul 29, 2004 3:40 am    Post subject: Reply with quote

this is the way i got it set up & that is how it tells me to do it .
with the fallowing urls.

ErrorDocument 400 /error/error.php?error=400
ErrorDocument 401 /error/error.php?error=401
ErrorDocument 403 /error/error.php?error=403
ErrorDocument 404 /error/error.php?error=404
ErrorDocument 500 /error/error.php?error=500

& i am suposta get that part in the script like
if some one gos to a page that is not there then thay would get
Error 400 look @ the script you will see in it the Error 400 part
but instead it is giveing the Unknown Error part of the script.
you see what i am talking about
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 29, 2004 3:53 am    Post subject: Reply with quote

Put each of the Short URL's in the console area and ignore the Apache
config directives , im assuming they want you to use Apache , example.

Error Code: 400
/error/error.php?error=400

Error Code: 403
/error/error.php?error=403

Error Code: 404
/error/error.php?error=404

Error Code: 500
/error/error.php?error=500

Is this how you setup your URL's in the console ?
Back to top View user's profile Send private message Visit poster's website
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Thu Jul 29, 2004 8:07 am    Post subject: Reply with quote

i did it like that i will go to the right page but the page is not right

the contint reads rong ok like say i am going to page is not there i would get 404 so i should get the 404 contint in the script but in instead i am geting contint Unknown Error of the script.

so how do i fix it
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Sat Jul 31, 2004 5:09 am    Post subject: Reply with quote

ok i guess no one knows how to help me out on this issue
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sat Jul 31, 2004 5:38 am    Post subject: Reply with quote

Override , I gave you a PM , can you please check your inbox
and send screenshots of the error like I told you. Thank You!
Back to top View user's profile Send private message Visit poster's website
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Sat Jul 31, 2004 6:17 am    Post subject: Reply with quote

ok now php is not working @ all now ??? now i got biger probs now & abyss is illeagal opping i got the beta v
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Sat Jul 31, 2004 6:40 am    Post subject: Reply with quote

n/m on the last post i got the server back but the script still giveing me a fit
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Override
-


Joined: 25 Nov 2003
Posts: 124
Location: Virtual Abyss N Area 61

PostPosted: Sat Jul 31, 2004 7:28 am    Post subject: Reply with quote

WOW I DID IT. IT WORKS

Thanks ever one That Tryed to help but i guess this is one of thows things
you hade to do on your on
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group