HeroSteve Posted December 9, 2012 Share Posted December 9, 2012 (edited) Hey guys, i'm a beginner to php so im trying to use this login registration system as a firm and strong foundation from this source "http://www.ineedtuto...em-php-tutorial" and i've met an error that im trying to fix for login.functions.php file on line 6 for syntax error, unexpected 'else' (T_ELSE). The code is: <?php function isLoggedIn() { if (isset($_SESSION['loginid'])){ t echo $_SESSION['username']; { { return true; // the user is loged in } else { return false; // not logged in } return false; } function checkLogin($u, $p) { global $seed; // if (!valid_username($u) || !valid_password($p) || !user_exists($u)) { return false; } $query = sprintf(" SELECT loginid FROM login WHERE username = '%s' AND password = '%s' AND disabled = 0 AND activated = 1 LIMIT 1;", mysql_real_escape_string($u), mysql_real_escape_string(sha1($p . $seed))); $result = mysql_query($query); if (mysql_num_rows($result) != 1) { return false; } else { $row = mysql_fetch_array($result); $_SESSION['loginid'] = $row['loginid']; $_SESSION['username'] = $u; return true; } return false; } ?> I've done some minor edits on session_is_registered with $_SESSION due to php updates but still dont know how to overcome the error. Can you please help me on this particular problem and some explainations on the problem would be wonderful. Thanks Edited December 9, 2012 by HeroSteve Quote Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/ Share on other sites More sharing options...
trq Posted December 9, 2012 Share Posted December 9, 2012 Have a look at line 6. Quote Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398341 Share on other sites More sharing options...
HeroSteve Posted December 9, 2012 Author Share Posted December 9, 2012 I cleared that mistake but still recieving the same error. Quote Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398344 Share on other sites More sharing options...
bugcoder Posted December 9, 2012 Share Posted December 9, 2012 rewriting first function for you and look for what is difference between yours and mine function isLoggedIn() { if (isset($_SESSION['loginid'])){ echo $_SESSION['username']; return true; // the user is loged in } else { return false; // not logged in } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398347 Share on other sites More sharing options...
HeroSteve Posted December 9, 2012 Author Share Posted December 9, 2012 rewriting first function for you and look for what is difference between yours and mine function isLoggedIn() { if (isset($_SESSION['loginid'])){ echo $_SESSION['username']; return true; // the user is loged in } else { return false; // not logged in } return false; } Thanks for the help much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/271779-unexpected-else-t_else-on-line-11-with-login-member-system/#findComment-1398351 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.