Jump to content

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


Bongeh

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.