Forum Moderators: coopster

Message Too Old, No Replies

Error in error code!

i've got an error in my error php code please help

         

cmatcme

6:57 pm on Jan 18, 2005 (gmt 0)

10+ Year Member



I am using this code to display error messages on my site:

-------------------------------------------------------
-------------------------------------------------------

<?
if ($_GET["error"]=="400") {
echo "<HEAD><TITLE>Error 400 :: Bad Syntax</TITLE></HEAD>
<BODY bgcolor=black text=white scrollbars=no>
<h4>
<B>Error Details: 400 - Bad Syntax </b></h4>
<hr color=silver width=350 align=left>
<br><br>
You have attempted to process a syntax which is 'bad'. If this syntax was processed due to a link or a service, please e-mail <a href=mailto:example@example.co.uk> here </a><br>

<br>
<a href=http://members.lycos.co.uk/example/index.php>HOME</a>

</body>";
} if ($_GET["error"]=="403"){
echo "<HEAD><TITLE>Error 403 :: Access Forbidden</TITLE></HEAD>
<BODY bgcolor=black text=white scrollbars=no>
<h4>
<B>Error Details: 403 - Access Forbidden </b></h4>
<hr color=silver width=350 align=left>
<br><br>
You attempted to access a directory or file without access. No-one accept The CMatterer has access to here as it may contain vital information for the website and its setup<br>

<br>
<a href=http://members.lycos.co.uk/example/index.php>HOME</a>

</body>";
} if ($_GET["error"]=="404") {
echo "<HEAD><TITLE>Error 404 :: Page Not Found</TITLE></HEAD>
<BODY bgcolor=black text=white scrollbars=no>
<h4>
<B>Error Details: 404 - Page Not Found </b></h4>
<hr color=silver width=350 align=left>
<br><br>
This error has occured due to the misleading of a link or to you typing in the wrong item in the address bar. If it was due to the misguidance of a link please the report it in this <a href=mailto:example@example.co.uk>email</a> to prevent this problem from reoccuring. If it was you who caused the error you'll know now to type it not again
<br>

<br>
<a href=http://members.lycos.co.uk/example/index.php>HOME</a>

</body>";
} if ($_GET["error"]=="500") {
echo "<HEAD><TITLE>Error 500 :: Internal Server Error</TITLE></HEAD>
<BODY bgcolor=black text=white scrollbars=no>
<h4>
<B>Error Details: 500 - Internal Server Error </b></h4>
<hr color=silver width=350 align=left>
<br><br>
This error is nothing for you to have concern over except that until the problem is fixed you can't use the page. Soon enough I will find out and it will be fixed. This problem is rare and usually takes ages to fix, so if this message due to an error, low chance of it fixing. Click refresh or come back in 3 hours if that fails.
<br>
<br>
Sorry...
<br>
<br>
<a href=http://members.lycos.co.uk/example/index.php>HOME</a>

</body>";
} if ($_GET["error"]=="502") {
echo"<HEAD><TITLE>Error 502 :: Overload</TITLE></HEAD>
<BODY bgcolor=black text=white scrollbars=no>
<h4>
<B>Error Details: 502 - Overload </b></h4>
<hr color=silver width=350 align=left>
<br><br>
If you know what traffic is on a website is, there's too much of it at the moment and if you don't click <a href=# onClick="window.open('index.php?error=502e', '402explain', 'width=500', 'height=150', 'resizable=no', 'scrollbars=yes', 'toolbar=no', 'location=no', 'directories=no', 'status=yes', 'menubar=no', 'copyhistory=no')">here</a><br>

<br>
<a href=http://members.lycos.co.uk/example/index.php>HOME</a>

</body>
";
} if ($_GET["error"]=="502e") {
echo"<head><title>Explaining Traffic </title> </head>
<body bgcolor=#000000 text=#FFFFFF">
<font color=WHITE size=3 face=Arial>Traffic on a website is how many people are visiting and opening the files on it (just like car traffic, how may people are visiting a certain destination). If too many people are opening files the traffic is jammed and the overload error appears. To solve it, just return to that page at a different time. This also applies to those reading this using XTRA </font>
</body>
";
}
?>

-------------------------------------------------------
-------------------------------------------------------

But this error message keeps being displayed:

Parse error: parse error, expecting `','' or `';'' in /data/members/free/tripod/uk/c/m/a/example/htdocs/errors/index.php on line 65

Can You Help?

[edited by: jatar_k at 7:08 pm (utc) on Jan. 18, 2005]
[edit reason] generalized and sidescroll fixed [/edit]

dreamcatcher

7:36 pm on Jan 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, your problem is that you are using double quotes inside an echo statment that also uses double quotes. This is the problem line:


<a href=# onClick="window.open('index.php?error=502e', '402explain', 'width=500', 'height=150', 'resizable=no', 'scrollbars=yes', 'toolbar=no', 'location=no', 'directories=no', 'status=yes', 'menubar=no', 'copyhistory=no')">

Once you code hits onClick=" it thinks the line has terminated and because there is no semi colon after it you get a parse error.

You should escape the double quotes at beginning and end of this line:


<a href=# onClick=\"window.open('index.php?error=502e', '402explain', 'width=500', 'height=150', 'resizable=no', 'scrollbars=yes', 'toolbar=no', 'location=no', 'directories=no', 'status=yes', 'menubar=no', 'copyhistory=no')\">

Alternatively, use single quotes in your echo statement.

echo ' etc etc

dc