new_born191285 Posted August 20, 2008 Share Posted August 20, 2008 Hi all, I have 2 undefined index errors which I don't know hot to solve (I am new to PHP) :quiet: I would appreciate it if anyone can help solve these 2 errors; [Notice: Undefined index: mode in /var/www/html/phpTrafficA-2.0.1/index.php on line 54 Notice: Undefined index: mode in /var/www/html/phpTrafficA-2.0.1/index.php on line 56 <?php if (!isset($mode) or $mode == "") { $mode = $_GET["mode"]; if ($mode == "") { $mode = $_POST["mode"];} ?> I'm running php 5.2.6 and have register_globals on if that helps Cheers, Link to comment https://forums.phpfreaks.com/topic/120496-undefined-index-_get-and-isset/ Share on other sites More sharing options...
Fadion Posted August 20, 2008 Share Posted August 20, 2008 Turn register_globals off, it is deprecated and will be removed in php6. About the problem, 'Undefined index' means that 'mode' isn't an array index. That means that you haven't a get variable and/or a post variable called 'mode'. Link to comment https://forums.phpfreaks.com/topic/120496-undefined-index-_get-and-isset/#findComment-620939 Share on other sites More sharing options...
kenrbnsn Posted August 20, 2008 Share Posted August 20, 2008 Use something like: <?php if (isset($_GET['mode'])) $mode = $_GET['mode']; if (!isset($mode) && isset($_POST['mode'])) $mode = $_POST['mode']; if (!isset($mode)) $mode = 'Error'; ?> And TURN OFF REGISTER GLOBALS (Yes, I'm shouting) Ken Link to comment https://forums.phpfreaks.com/topic/120496-undefined-index-_get-and-isset/#findComment-621032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.