adamjones Posted February 18, 2009 Share Posted February 18, 2009 Hi. The idea of this code is to echo some user information if the user is logged in, or if they aren't logged in, to echo a login menu; <?php session_start(); if(session_is_registered(name)){ echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back echo $_SESSION['name'];!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on echo $_SESSION['lastlogin'];</span></a></li>"; } else { echo "<li class='right logout'><a href='create.php' rel='facebox'><span>Create An Account</span></a></li> <li class='right logout'><a href='login.php' rel='facebox'><span>Login</span></a></li>"; } ?> But I get this error; "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/wowdream/public_html/designbyfreedom/habhub/index.php on line 4" Quote Link to comment Share on other sites More sharing options...
adamjones Posted February 18, 2009 Author Share Posted February 18, 2009 I'm pretty sure the problem is trying to echo the variables? I'm not sue how I would echo them, in an echo; If that makes sense? Quote Link to comment Share on other sites More sharing options...
blueman378 Posted February 18, 2009 Share Posted February 18, 2009 if a varialb is already inside an echo you dont need echo again try something like this echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back $_SESSION['name']!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on $_SESSION['lastlogin']</span></a></li>"; youll need to change your else as well Quote Link to comment Share on other sites More sharing options...
blueman378 Posted February 18, 2009 Share Posted February 18, 2009 the correct way is to acctually break out of the echo with . but in this case you dont need it. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted February 18, 2009 Share Posted February 18, 2009 btw check your functions, you are using depreciated functions such as session_is_registered(name) Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted February 18, 2009 Share Posted February 18, 2009 <?php session_start(); if(session_is_registered(name)){ echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back ".echo $_SESSION['name'];."!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on ".echo $_SESSION['lastlogin'];."</span></a></li>"; } else { echo "<li class='right logout'><a href='create.php' rel='facebox'><span>Create An Account</span></a></li> <li class='right logout'><a href='login.php' rel='facebox'><span>Login</span></a></li>"; } ?> Try that (Only fixed a few things, not the depreciated functions..) Quote Link to comment Share on other sites More sharing options...
adamjones Posted February 18, 2009 Author Share Posted February 18, 2009 <?php session_start(); if(session_is_registered(name)){ echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back ".echo $_SESSION['name'];."!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on ".echo $_SESSION['lastlogin'];."</span></a></li>"; } else { echo "<li class='right logout'><a href='create.php' rel='facebox'><span>Create An Account</span></a></li> <li class='right logout'><a href='login.php' rel='facebox'><span>Login</span></a></li>"; } ?> Try that (Only fixed a few things, not the depreciated functions..) Hi, thanks. But now I get this error; "Parse error: syntax error, unexpected T_ECHO in /home/wowdream/public_html/designbyfreedom/habhub/index.php on line 4" Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2009 Share Posted February 18, 2009 Youve already called echo, no need to do it again. <?php session_start(); if (isset($_SERSSION['name'])) { echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back {$_SESSION['name']}!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on {$_SESSION['lastlogin']}</span></a></li>"; } else { echo "<li class='right logout'><a href='create.php' rel='facebox'><span>Create An Account</span></a></li> <li class='right logout'><a href='login.php' rel='facebox'><span>Login</span></a></li>"; } ?> ps: session_is_registered has LONG been depricated. Quote Link to comment Share on other sites More sharing options...
killah Posted February 18, 2009 Share Posted February 18, 2009 Thorpe, might want to overlook your code there . I've never heard of the global variable of "$_SERSSION[]". Quote Link to comment Share on other sites More sharing options...
adamjones Posted February 18, 2009 Author Share Posted February 18, 2009 Youve already called echo, no need to do it again. <?php session_start(); if (isset($_SERSSION['name'])) { echo "<li class='right active'><a href='account_settings.php' rel='facebox'><span>Welcome back {$_SESSION['name']}!</span></a></li> <li class='right active'><a href='' rel='facebox'><span>Last login on {$_SESSION['lastlogin']}</span></a></li>"; } else { echo "<li class='right logout'><a href='create.php' rel='facebox'><span>Create An Account</span></a></li> <li class='right logout'><a href='login.php' rel='facebox'><span>Login</span></a></li>"; } ?> ps: session_is_registered has LONG been depricated. Thankyou very much for your help. All working now; I'm still learning, well, trying to! Haha. Quote Link to comment Share on other sites More sharing options...
killah Posted February 18, 2009 Share Posted February 18, 2009 Might want to change if (isset($_SERSSION['name'])) { to if (isset($_SESSION['name'])) { Quote Link to comment Share on other sites More sharing options...
adamjones Posted February 18, 2009 Author Share Posted February 18, 2009 Might want to change if (isset($_SERSSION['name'])) { to if (isset($_SESSION['name'])) { Saw that; It was the only one I could change by myself! Lol. Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2009 Share Posted February 18, 2009 Thorpe, might want to overlook your code there . I've never heard of the global variable of "$_SERSSION[]". Funnily enough I don't test my code, and a few typos are bound to occur after a few wines. Quote Link to comment 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.