Jump to content

[SOLVED] Problem with if (empty($location)) on Windows Server 2003 webhost


Recommended Posts

$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!

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.