ecabrera Posted October 16, 2011 Share Posted October 16, 2011 giving me Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/enriquec/public_html/admincenter.php on line 6 this is my code <?php require "header.php";?> <?php if ($_SESSION['username']) echo "Welcome, "."$_SESSION['username']."; else die("You must be logged in!"); ?> <?php require "footer.php":?> Quote Link to comment https://forums.phpfreaks.com/topic/249224-session/ Share on other sites More sharing options...
codefossa Posted October 16, 2011 Share Posted October 16, 2011 <?php include_once('header.php'); ?> <?php if ($_SESSION['username']) echo "Welcome, {$_SESSION['username']}"; else die("You must be logged in!"); ?> <?php include_once('footer.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/249224-session/#findComment-1279809 Share on other sites More sharing options...
Drummin Posted October 17, 2011 Share Posted October 17, 2011 <?php require "header.php";?> Bracket the results of your if else statements. <?php if ($_SESSION['username']){ echo "Welcome, "."$_SESSION['username']."; } else{ die("You must be logged in!"); } ?> <?php require "footer.php":?> Quote Link to comment https://forums.phpfreaks.com/topic/249224-session/#findComment-1279839 Share on other sites More sharing options...
AyKay47 Posted October 17, 2011 Share Posted October 17, 2011 Kira fixed the issue here, the problem was in the concatenation of $_SESSION['username'] in line 6.. since the if else statements are single lines of code, curly braces are not needed here.. Quote Link to comment https://forums.phpfreaks.com/topic/249224-session/#findComment-1279912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.