Bongeh Posted September 25, 2008 Share Posted September 25, 2008 $location=$_GET['location']; if (empty($location)) { $location='index'; } changelocation($location); function changelocation($location) switch ($location) { case 'index': include ('actualindex.html'); break; case 'page2': include ('page2.html'); break; } As i understand it, if there is no location stated in the url the php tells it to use actualindex.html, it was working fine but now i am getting this error, the only thing thats changed is the web server changed from linux to windows server 2003 Notice: Undefined index: location in E:\domains\p\paulmcallen.co.uk\user\htdocs\new\index.php on line 3 I am quite new to php so sorry if this is a dead simple fix! Quote Link to comment https://forums.phpfreaks.com/topic/125757-solved-problem-with-if-emptylocation-on-windows-server-2003-webhost/ Share on other sites More sharing options...
Zane Posted September 25, 2008 Share Posted September 25, 2008 you need to use isset before you set a variable to $_GET['location'] $location = isset($_GET['location']) ? $_GET['location'] : 'index'; Quote Link to comment https://forums.phpfreaks.com/topic/125757-solved-problem-with-if-emptylocation-on-windows-server-2003-webhost/#findComment-650299 Share on other sites More sharing options...
Bongeh Posted September 25, 2008 Author Share Posted September 25, 2008 ah thank you!, is it lazy coding, or something windows doesn't do that Linux does? Quote Link to comment https://forums.phpfreaks.com/topic/125757-solved-problem-with-if-emptylocation-on-windows-server-2003-webhost/#findComment-650300 Share on other sites More sharing options...
Zane Posted September 25, 2008 Share Posted September 25, 2008 no....nothing to do with the operating system. imagine this scenario you are saying $location = $_GET['location'] that's assuming that you ALWAYS have a location var in your URL....so what does that code do when you don't have location in your url... IT FAILS so you first have to check if it even exists first...which is why you got that error. undefined index. Quote Link to comment https://forums.phpfreaks.com/topic/125757-solved-problem-with-if-emptylocation-on-windows-server-2003-webhost/#findComment-650302 Share on other sites More sharing options...
Bongeh Posted September 25, 2008 Author Share Posted September 25, 2008 right okay, cheers buddy! thanks for fixing my problem and explaining it too! five stars! Quote Link to comment https://forums.phpfreaks.com/topic/125757-solved-problem-with-if-emptylocation-on-windows-server-2003-webhost/#findComment-650309 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.