limitphp Posted July 11, 2009 Share Posted July 11, 2009 Notice: Undefined index: loginMode in C:\wamp\www\inc_login_script.php on line 2 I'm not sure what is wrong here. In the index.php file I have an include: include("inc_login_script.php"); In the inc_login_script.php on line 2 is this: $loginMode = $_POST['loginMode']; I just installed wamp server 5.2.9-2 Is there another setting I need to turn on? Quote Link to comment Share on other sites More sharing options...
mattal999 Posted July 11, 2009 Share Posted July 11, 2009 You should check if it is set first: <?php if(isset($_POST['loginMode']) && $_POST['loginMode'] !== "") { $loginMode = $_POST['loginMode']; } ?> Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 Nope. You need to check if the index 'loginMode' exists in $_POST array, before you try to assign its value to anything. if(isset($_POST['loginMode'])) { $loginMode = $_POST['loginMode']; } Or you can just disable reporting of E_NOTICE level error messages. Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 Is this a new error? I don't remember getting all these errors, several months ago when I had wamp server installed? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Is this a new error? I don't remember getting all these errors, several months ago when I had wamp server installed? Your previous installation most probably had a setting called display_errors disabled or the error_reporting level was set to ignore notices. Notices are not errors, these do not prevent your script from running however they are simple to correct. Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 Its actually giving me another : Notice: Undefined variable: s in C:\wamp\www\inc_login_script.php on line 5 on line 5 I have this: $salt = "®$s:<š1ašskj67^&&*&*"; It thinks I'm declaring s because there is a $ sign in front of it. Can you not have a dollar sign as part of a value in a variable? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Change the double quoes to single quotes. Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 That's because default error levels have changed in WampServer's recent version. Notices are not serious errors . They're rather indicating parts of your code, that might lead to unexpected behaviour. As I said, you can just disable these messages (look in php.ini for error_reporting). This will make your script work, but is not a recommended thing to do. The proper line of action is to correct your code, so that no notices are thrown. [edit] See? The actual value of $salt was not ®$s:<š1ašskj67^&&*&* but ®:<š1ašskj67^&&*&* Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 Change the double quoes to single quotes. That actually got rid of that one....thanks... "As I said, you can just disable these messages (look in php.ini for error_reporting). This will make your script work, but is not a recommended thing to do. The proper line of action is to correct your code, so that no notices are thrown." Thats what I'd like to do, but I have so many dang notices, its going to take me a while to fix them all.... Notice: Undefined index: loginMode in C:\wamp\www\inc_login_script.php on line 2 Notice: Undefined index: logout in C:\wamp\www\inc_login_script.php on line 3 Notice: Undefined index: time in C:\wamp\www\index.php on line 10 Notice: Undefined index: genre in C:\wamp\www\index.php on line 33 Notice: Undefined index: genres in C:\wamp\www\index.php on line 44 Notice: Undefined variable: genres in C:\wamp\www\index.php on line 54 Notice: Undefined index: currentpage in C:\wamp\www\index.php on line 172 Notice: Undefined variable: audioplayer_soundfiles in C:\wamp\www\inc_vote_view.php on line 31 Notice: Undefined variable: audioplayer_artists in C:\wamp\www\inc_vote_view.php on line 32 Notice: Undefined variable: audioplayer_titles in C:\wamp\www\inc_vote_view.php on line 33 Notice: Undefined variable: loginFailureMessage in C:\wamp\www\index.php on line 410 Are you supposed to declare variables before you use them? Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 You should. Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 How do you declare them? Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 $integer = 0; $float = 0.0; $string = ''; $array = array(); You can of course use other initial values if needed Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 $integer = 0; $float = 0.0; $string = ''; $array = array(); You can of course use other initial values if needed What about this example: //********************************** HANDLE TIME ****************** if($_GET['time']) //*****Get Existing time Value { $time = $_GET['time']; } elseif($_SESSION['time']) { $time = $_SESSION['time']; } //Validate $time = ceil($time); if(empty($time) || !is_numeric($time) || $time < 1 || $time>365) { $time = 60; } //Set Session variable for next time $_SESSION['time'] = $time; //************************************************************************* If time doesn't exist, I want to do something.... I'm thinking, I don't understand another basic principle of coding.... Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 if(isset($_GET['time'])) //*****Get Existing time Value { $time = $_GET['time']; } elseif(isset($_SESSION['time'])) { $time = $_SESSION['time']; } etc.. Quote Link to comment Share on other sites More sharing options...
limitphp Posted July 11, 2009 Author Share Posted July 11, 2009 if(isset($_GET['time'])) //*****Get Existing time Value { $time = $_GET['time']; } elseif(isset($_SESSION['time'])) { $time = $_SESSION['time']; } etc.. So, I need to start using the isset? thanks 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.