View Full Version : Parse error: parse error, unexpected T_ELSE
Helios 11-13-2002, 03:56 AM K, I have this set, and I have been trying to figure it out for about 2 hours. I'm sure its a no brainer, but what does this error mean? I've checked my if/elseif/else statements and they are all closed properly and ordered properly.
:uzi:
i am a 11-13-2002, 04:53 AM it's usually because you may be missing a > in an array assignment..
ex.
$array = array(
assign = "me",
assign2 =>" me2"
);
the error would be the missing ">" in assign = "me"
Rich2k 11-13-2002, 05:28 AM I quite often find it can be caused by forgetting to close a loop.
Bulldog 11-13-2002, 10:48 AM The code should be:
$array = array(
assign = "me",
assign2 => "me2"
);
jtrovato 11-13-2002, 05:53 PM what is the code can you send it over so we can see??
Helios 11-14-2002, 02:24 PM <?php
session_start();
if (!isset($_SESSION['username']) | !isset($_SESSION['password'])) {
$message = "<p>Wrong Username or Password.<br>\nPlease return to the login screen and try again.<br>\nIf there is a login problem,<br>\n Contact a Site Administrator.</p>\n";
$error = 'Login Failed';
//INCLUDE LINK BACK TO LOGIN PAGE!!!!! DON'T FORGET!!!!
}//Check to make sure admin access is right
elseif ( $login != 2 ) {
$message = "<p>You do not have clearance to access this page.<br>\nIf there is a problem,<br>\n Contact a Site Administrator.</p>\n";
$error = 'Access Failed';
//INCLUDE LINK BACK TO LOGIN PAGE!!!!! DON'T FORGET!!!!
}
if (isset($error)) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo '$error';?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../stylesheet/default.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><?php echo '$message';?></p>
</div></td>
</tr>
</table>
</body>
</html>
<?php
}
else{
?>
//The contents of my website are here
<?php
}
?>
sasha 11-14-2002, 02:33 PM <?php echo '$error';?>
should be
<? echo $error ;?>
Helios 11-14-2002, 02:34 PM oh, the upper portion (until it gets to the //contents of the website are here) is in a seperate include file labeled header.php. The bottom is labeled footer.php
So my actual page page looks like this:
<?php
include('header.php')
?>
Web Page here
<?php
include('footer.php')
?>
Helios 11-14-2002, 02:41 PM I tried that Sasha, it was what I had originally. However that won't cause the parse error I've been getting.
I've been trying everything to get this to work.
jtrovato 11-14-2002, 02:55 PM man you still working on this what line does it say your error is in? and what is the entire error
john
Helios 11-14-2002, 03:25 PM Parse error: parse error, unexpected $ in header.php on line 36
Parse error: parse error, unexpected T_ELSE in header.php on line 43
Maybe I'm just going batty.
Helios 11-14-2002, 03:53 PM I am batty!
There is something wrong with the way it is parsed with the includes. I put all of my header and my footer into the same page and tried it out, voila! Nothign wrong, no parse errors, no nothing! I'm really itching my head now...
<?php
session_start();
if (!isset($_SESSION['username']) | !isset($_SESSION['password'])) {
$message = "<p>You are not logged in.<br>\nPlease return to the login screen and try again.<br>\nIf there is a login problem,<br>\n Contact a Site Administrator.</p>\n";
$error = 'Login Failed';
//INCLUDE LINK BACK TO LOGIN PAGE!!!!! DON'T FORGET!!!!
}//Check to make sure admin access is right
elseif ( $admin != 2 ) {
$message = "<p>You do not have clearance to access this page.<br>\nIf there is a problem,<br>\n Contact a Site Administrator.</p>\n";
$error = 'Access Failed';
//INCLUDE LINK BACK TO LOGIN PAGE!!!!! DON'T FORGET!!!!
}
if (isset($error)) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $error;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../stylesheet/default.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><?php echo $message;?></p>
</div></td>
</tr>
</table>
</body>
</html>
<?php
}
else{
?>
Test Successful!!
<?php
}
?>
sasha 11-14-2002, 04:38 PM include('header.php') with ; after
if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
|| no | if you want OR
Helios 11-14-2002, 04:57 PM Well that session information is in the header. Is that what the problem is?
Rather then writing out the Session in each page that uses it, I just put it in its own include file. So if I had to change it or something later, I wouldn't have to backtrack through 102 pages.
I appreciate all the help this board and you guys give me. Its really nice to have some people answer the questions that cause confusion.
:beer:
jtrovato 11-14-2002, 06:54 PM I tested the script and it worked fine
www.classicalevents.ocm/test/test.php
I know I didn't have the variable registered. But I didn't get ant errors either.
John
jtrovato 11-14-2002, 07:44 PM www.classicalevents.com/test/test.php
|