Parse error, according to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rnoack
Forum Commoner
Posts: 34
Joined: Mon May 03, 2010 12:38 am

Parse error, according to php

Post 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
rahulzatakia
Forum Commoner
Posts: 59
Joined: Fri Feb 05, 2010 12:01 am
Location: Ahmedabad

Re: Parse error, according to php

Post 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.
rnoack
Forum Commoner
Posts: 34
Joined: Mon May 03, 2010 12:38 am

Re: Parse error, according to php

Post 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!
rnoack
Forum Commoner
Posts: 34
Joined: Mon May 03, 2010 12:38 am

Re: Parse error, according to php

Post 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
Post Reply