jarv Posted October 24, 2010 Share Posted October 24, 2010 Please help, I just added an IF statement to my code and now I get: Undefined index: rsUser while($row = mysql_fetch_array($result)) { echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>'; if ($_SESSION["rsUser"] == "admin") { "<a href=\"edit.php?PUBID=".$PUB['PubID']."\" class=\"small\">edit this pub</a>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/ Share on other sites More sharing options...
Pikachu2000 Posted October 24, 2010 Share Posted October 24, 2010 Then $_SESSION['rsUser'] hasn't been defined at the point in the script where you attempt to access its value. Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125937 Share on other sites More sharing options...
jarv Posted October 24, 2010 Author Share Posted October 24, 2010 but it is set in my functions: function cleanMemberSession($login, $password) { /* Member session initialization function: This function initializes 3 session variables: $login, $password and $loggedIn. $login and $password are used on member pages (where you could allow the user to change their password for example). $loggedIn is a simple boolean variable which indicates whether or not the user is currently logged in. */ $_SESSION["RSUSER"]=$login; $_SESSION["RSPASS"]=$password; $_SESSION["loggedIn"]=true; Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125952 Share on other sites More sharing options...
Adam Posted October 24, 2010 Share Posted October 24, 2010 'rsUser' != 'RSUSER' Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125957 Share on other sites More sharing options...
tastro Posted October 24, 2010 Share Posted October 24, 2010 lower and uppercase are not the same in php or just in sessions? didn't knew that even myself. Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125979 Share on other sites More sharing options...
Adam Posted October 24, 2010 Share Posted October 24, 2010 Variables and array indexes are case-sensitive, functions and class names aren't. Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125982 Share on other sites More sharing options...
jarv Posted October 24, 2010 Author Share Posted October 24, 2010 Thanks! sorted now! Quote Link to comment https://forums.phpfreaks.com/topic/216727-added-an-if-statement-and-now-i-get-undefined-index-rsuser/#findComment-1125990 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.