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" Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/ 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? Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765024 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 Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765044 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. Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765045 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) Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765046 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..) Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765048 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" Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765053 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. Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765065 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[]". Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765070 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. Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765073 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'])) { Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765074 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. Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765076 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. Link to comment https://forums.phpfreaks.com/topic/145707-solved-code-not-working/#findComment-765085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.