Page 1 of 1

Parse error, according to php

Posted: Mon May 03, 2010 12:49 am
by rnoack
Well, I don't think i've ever spent so many hours looking at a single line of code. For some reason the following code is generating an error:
Parse error: syntax error, unexpected '{' in menu.php on line 1

Code: Select all

<div class="centerBorderBox" id="menu">
<p class="center"><b>Logged in user: </b><?php echo $login; ?><input type="button" value="Logout" action="logout.php?auth=<?php echo $auth; ?>"></p>
<p class="center">
<?php
if(isset($Pneed_approval)) { echo "<span class=\"bold\" style=\"color:maroon\">Your account is awaiting activation.</span>"; }
 ?>
</p>
</div>
yes - that is the entire file. it is intended to be included by another file, but i am still getting the error accessing directly.

When I remove this line the error goes away:

Code: Select all

if(isset($Pneed_approval)) { echo "<span class=\"bold\" style=\"color:maroon\">Your account is awaiting activation.</span>"; }




in addition this code gives me Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in menu.php on line 1

Code: Select all

<div class="centerBorderBox" id="menu">
<p class="center"><b>Logged in user: </b><?php echo $login; ?><input type="button" value="Logout" action="logout.php?auth=<?php echo $auth; ?>"></p>
<p class="center">
<?php
echo "hello";
 ?>
</p>
</div>
but this works fine

Code: Select all

<div class="centerBorderBox" id="menu">
<p class="center"><b>Logged in user: </b><?php echo $login; ?><input type="button" value="Logout" action="logout.php?auth=<?php echo $auth; ?>"></p>
<p class="center">
<?php

 ?>
</p>
</div>


I do not understand at all what is going on... I have hundreds of other php files doing this exact same thing with no issue. Please tell me there is some logical explanation for this... thanks in advance

Re: Parse error, according to php

Posted: Mon May 03, 2010 1:29 am
by rahulzatakia
Hi, I have tried both the codes and its working fine with me.. so please check out the code above and below the code you provided.

Re: Parse error, according to php

Posted: Mon May 03, 2010 7:48 am
by rnoack
weird. i also tried pasting the syntax from here into a new php file at it works.
but if i copy paste from notepad++ it doesn't work in the new file either.


i didn't think anything was wrong with the code.... i guess the file just got oddly corrupted... and ruined 2 hours of my life!!!! argh!

Re: Parse error, according to php

Posted: Mon May 03, 2010 9:43 am
by rnoack
I figured out what the original problem was.

the line

<?php
if .....


did not have a space after "<?php ",
so it was being read as <?phpif

= error