jrtime Posted June 24, 2011 Share Posted June 24, 2011 I had a simple php page, that I think was written in php 3 that would only display a page if a user had logged on: session_start(); $username = "bob"; if ($_SESSION['user'] != $username) {?> <?php echo "You must logon."; echo "<a href='login.php'>Logon<a/>; ?> <?php } else} ?> <html> </html> <?php } ?>[code] This worked fine till the server was updated to only accept php 5(Server information shows PHP Version: 5.2.12). Now, I am getting a parse error: Parse error: syntax error, unexpected '}' , which is the } in the following section: [code]<?php } else [code] I ran the page through syntax checkers for php 5, and it it showing up as coded okay, but it is not working. Can anyone see what I am doing wrong or need to updated to make this work? Thanks! Link to comment https://forums.phpfreaks.com/topic/240310-if-else-page-to-see-if-a-user-is-logged-on-needs-upgraded-to-php-5/ Share on other sites More sharing options...
Nuv Posted June 24, 2011 Share Posted June 24, 2011 <?php session_start(); $username = "bob"; if ($_SESSION['user'] != $username) {?> <?php echo "You must logon."; echo "<a href='login.php'>Logon<a/>; ?> <?php } else{ // You need to start { and not close } here ?> <html> </html> <?php } ?> In <?php } else} ?> it should be <?php } else { ?> Link to comment https://forums.phpfreaks.com/topic/240310-if-else-page-to-see-if-a-user-is-logged-on-needs-upgraded-to-php-5/#findComment-1234357 Share on other sites More sharing options...
trq Posted June 24, 2011 Share Posted June 24, 2011 It's missing the opening <?php tags. Link to comment https://forums.phpfreaks.com/topic/240310-if-else-page-to-see-if-a-user-is-logged-on-needs-upgraded-to-php-5/#findComment-1234358 Share on other sites More sharing options...
jrtime Posted June 28, 2011 Author Share Posted June 28, 2011 That worked great. I guess it has been wrong for some time and the older php on the server had been more forgiving. Thanks again. Link to comment https://forums.phpfreaks.com/topic/240310-if-else-page-to-see-if-a-user-is-logged-on-needs-upgraded-to-php-5/#findComment-1236051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.