tmyonline Posted April 27, 2009 Share Posted April 27, 2009 Guys, I'm not sure if this is a PHP problem but since my program is coded in PHP, so I hope to get some help here. My program works fine locally but when uploading it to the server, it complains: Notice: Undefined index: time in xyz.php line 44 Notice: Undefined index: type in abc.php line 60 When I looked at these two lines, I see that it complains about the $_GET['time'] and $_GET['type'] respectively. Look like the $_GET['time'] and $_GET['type'] have not been defined at the time but I have used the isset() to detect it, i.e., if (isset($_GET['time'])) { ... } but it still complains. Any ideas ? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/ Share on other sites More sharing options...
wildteen88 Posted April 27, 2009 Share Posted April 27, 2009 You need to post more code. Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-820478 Share on other sites More sharing options...
tmyonline Posted April 27, 2009 Author Share Posted April 27, 2009 OK here it is: public function doIt() { if ($_GET['download'] == 'true') $this->writeToExcel(); else { $this->displayHtmlHeader(); $this->displayOutageInfo(); $this->displayHtmlBottom(); } } My program works fine locally. The problem only happens on the server. It complains: Undefined index: download in /test/xyz.php line 40 and line 40 is: if ($_GET['download'] == 'true') Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-820482 Share on other sites More sharing options...
jackpf Posted April 27, 2009 Share Posted April 27, 2009 Because download is not in the query string. Try this: if(isset($_GET['download']) && $_GET['download'] == 'true') Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-820484 Share on other sites More sharing options...
Daniel0 Posted April 27, 2009 Share Posted April 27, 2009 My program works fine locally. No, it does not. You've just set a lower error reporting level. Set it to E_ALL | E_STRICT. Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-820487 Share on other sites More sharing options...
jackpf Posted April 27, 2009 Share Posted April 27, 2009 Well...depends what you define "fine" as. I wouldn't really consider a warning a proper error. For example, $var = end(explode('something', 'something ')); Will give a warning, because end() expects an array, not a function or something. But $var = explode('something', 'something '); $var = end($var); Will not. I don't really see anything wrong with the first piece of code tbh. Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-820497 Share on other sites More sharing options...
tmyonline Posted April 29, 2009 Author Share Posted April 29, 2009 Thanks guys. It worked. Quote Link to comment https://forums.phpfreaks.com/topic/155878-solved-problem-with-undefined-index/#findComment-821756 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.