$_GET and $_REQUEST causing Internal Server Errors [Fixed]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

$_GET and $_REQUEST causing Internal Server Errors [Fixed]

Post by PeteA »

[FIXED]Please see for solution: viewtopic.php?f=1&t=119344&start=30#p618333

I have a really strange problem with a web host that I've recently signed up to.

So I have some code which is pretty standard as you may agree. (narrowed it down to get and set in a system I'm creating)

Code: Select all

<?php
	$hello = $_GET['hello'];
	echo $hello;
?>
The problem is if the url is hello.php it returns a Internal Server Error 500.
If the url is hello.php?hello it works

I'm a fairly intermediate php programmer and have never in all my time with servers and hosting come across this. I've tried replicating it locally to no avail and the web host just says don't use that code use something else or it's a problem with your code. Which is fairly useless to me.

Has anyone got any ideas how I can get around this. I still need to use $_GET or $_REQUEST. Just really need the page to parse if the url vars do not exist.

It looks a bit rubbish if someone just goes to hello.php or infact the system I'm making it'll be under index.php so the whole lot wouldn't show anyway.

The server is Windows Server 2008 IIS, and the PHP version is 5.

Thanks in advance.
Last edited by PeteA on Mon Aug 02, 2010 1:53 pm, edited 3 times in total.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Try hello.php?hello=

I think might be breaking because you aren't defining a variable in the query with proper syntax.
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

yep that works as I said in my previous post, the problem is I'm planning on having this at base url so I need to figure out a way round this. I cant seem to find anyone else who has had this specific problem before.

I doubt I'll be able to cancel the hosting so I want to get round the issue.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Oh, sorry, misunderstood your question.

Try this, just to test:

Code: Select all

<?php var_dump($_SERVER['QUERY_STRING']); ?>
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

Code: Select all

string(0) ""
I've also tried a $_SESSION test and that doesn't seem to have a problem, so it seems to be localised to URL requests.

Any ideas how I can check if there are any vars in the url and then do the get?
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Did you run that on hello.php?hello or just on hello.php? You can do a count on that array to check if there are any query variables, and then perform the $_GET function. But I honestly have no idea why that wouldn't be working...are you sure that it's from that specific section of the code? Maybe post the entire page so we can take a look and make sure you didn't miss anything.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by AbraCadaver »

I don't know why you would get a 500 internal server error, but try this:

Code: Select all

if(isset($_GET['hello'])) {
   $hello = $_GET['hello']
} else {
   $hello = 'something else';
}
echo $hello;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

jraede wrote:Did you run that on hello.php?hello or just on hello.php? You can do a count on that array to check if there are any query variables, and then perform the $_GET function. But I honestly have no idea why that wouldn't be working...are you sure that it's from that specific section of the code? Maybe post the entire page so we can take a look and make sure you didn't miss anything.
Yes I'm sure that it's that. I've just literally tested the original code I posted and it errors. It's the strangest thing.

With hello.php?hello=Pete

string(10) "hello=Pete"

hello.php with it Internal Errors, sorry I messed up that one.

AbraCadaver wrote:I don't know why you would get a 500 internal server error, but try this:

Code: Select all

if(isset($_GET['hello'])) {
   $hello = $_GET['hello']
} else {
   $hello = 'something else';
}
echo $hello;
Server Error

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Does every page without a get request not work? Or does it just not work when you try to use the $_GET variable? I read this and it said there could be a problem with the htaccess file, which may explain why it only happens with a GET query, perhaps due to an unbroken redirect loop. That article also suggests there could be a problem with the ini, but if other PHP functions are working I don't think that would be it.
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

Happens with get $_GET or $_REQUEST.

Just tried this:

Code: Select all

<?php
	$var = false;
	if($var = true)
	{
		$hello = $_GET['hello'];
		echo $hello;
	}
	else echo $var;
	var_dump($_SERVER['QUERY_STRING']);
?>
So it shouldn't even be executed because var is false and it still causes an error. This is really annoying now.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

What does your htaccess file look like?
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

I'm on windows with iis, so there isn't one.
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Is there a php.ini file?
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

No don't have access, I've asked but they wont do it.

Hope the bellow helps though

Code: Select all

PHP Version 5.2.6


System	Windows NT WINWEB05 6.0 build 6001
Build Date	May 2 2008 19:36:50
Configure Command	cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" "--disable-zts" "--disable-isapi" "--disable-activescript" "--with-extra-includes=C:\Program Files (x86)\Microsoft SDK\Include;C:\PROGRA~2\MICROS~2\VC98\ATL\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\MFC\INCLUDE" "--with-extra-libs=C:\Program Files (x86)\Microsoft SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"
Server API	CGI/FastCGI
Virtual Directory Support	disabled
Configuration File (php.ini) Path	C:\Windows
Loaded Configuration File	C:\PHP\php.ini
PHP API	20041225
PHP Extension	20060613
Zend Extension	220060519
Debug Build	no
Thread Safety	disabled
Zend Memory Manager	enabled
IPv6 Support	enabled
Registered PHP Streams	php, file, data, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports	tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters	convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, co

Code: Select all

PHP Variables

Variable	Value
_REQUEST["__utmz"]	125373964.1280263034.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
_REQUEST["__utma"]	125373964.1175761437.1280263034.1280332829.1280339810.5
_COOKIE["__utmz"]	125373964.1280263034.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
_COOKIE["__utma"]	125373964.1175761437.1280263034.1280332829.1280339810.5
_SERVER["ALLUSERSPROFILE"]	C:\ProgramData
_SERVER["APPDATA"]	C:\Windows\system32\config\systemprofile\AppData\Roaming
_SERVER["APP_POOL_ID"]	mydomain.co.uk_pool
_SERVER["CommonProgramFiles"]	C:\Program Files (x86)\Common Files
_SERVER["CommonProgramFiles(x86)"]	C:\Program Files (x86)\Common Files
_SERVER["CommonProgramW6432"]	C:\Program Files\Common Files
_SERVER["COMPUTERNAME"]	WINWEB05
_SERVER["ComSpec"]	C:\Windows\system32\cmd.exe
_SERVER["FP_NO_HOST_CHECK"]	NO
_SERVER["LOCALAPPDATA"]	C:\Windows\system32\config\systemprofile\AppData\Local
_SERVER["NUMBER_OF_PROCESSORS"]	8
_SERVER["OS"]	Windows_NT
_SERVER["Path"]	C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
_SERVER["PATHEXT"]	.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
_SERVER["PROCESSOR_ARCHITECTURE"]	x86
_SERVER["PROCESSOR_ARCHITEW6432"]	AMD64
_SERVER["PROCESSOR_IDENTIFIER"]	Intel64 Family 6 Model 23 Stepping 10, GenuineIntel
_SERVER["PROCESSOR_LEVEL"]	6
_SERVER["PROCESSOR_REVISION"]	170a
_SERVER["ProgramData"]	C:\ProgramData
_SERVER["ProgramFiles"]	C:\Program Files (x86)
_SERVER["ProgramFiles(x86)"]	C:\Program Files (x86)
_SERVER["ProgramW6432"]	C:\Program Files
_SERVER["PUBLIC"]	C:\Users\Public
_SERVER["SystemDrive"]	C:
_SERVER["SystemRoot"]	C:\Windows
_SERVER["TEMP"]	C:\Windows\TEMP
_SERVER["TMP"]	C:\Windows\TEMP
_SERVER["USERDOMAIN"]	WINVH1
_SERVER["USERNAME"]	WINWEB05$
_SERVER["USERPROFILE"]	C:\Windows\system32\config\systemprofile
_SERVER["windir"]	C:\Windows
_SERVER["FCGI_ROLE"]	RESPONDER
_SERVER["HTTP_CONNECTION"]	keep-alive
_SERVER["HTTP_ACCEPT"]	application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
_SERVER["HTTP_ACCEPT_CHARSET"]	ISO-8859-1,utf-8;q=0.7,*;q=0.3
_SERVER["HTTP_ACCEPT_ENCODING"]	gzip,deflate,sdch
_SERVER["HTTP_ACCEPT_LANGUAGE"]	en-GB,en-US;q=0.8,en;q=0.6
_SERVER["HTTP_COOKIE"]	__utmz=125373964.1280263034.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=125373964.1175761437.1280263034.1280332829.1280339810.5
_SERVER["HTTP_HOST"]	http://www.mydomain.co.uk
_SERVER["HTTP_USER_AGENT"]	Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.125 Safari/533.4
_SERVER["DOCUMENT_ROOT"]	E:\Domains\w\mydomain.co.uk\user\htdocs
_SERVER["REQUEST_URI"]	/testing.php
_SERVER["SCRIPT_FILENAME"]	E:\Domains\w\mydomain.co.uk\user\htdocs\testing.php
_SERVER["APPL_MD_PATH"]	/LM/W3SVC/7466002/ROOT
_SERVER["APPL_PHYSICAL_PATH"]	E:\Domains\w\mydomain.co.uk\user\htdocs\
_SERVER["AUTH_TYPE"]	no value
_SERVER["AUTH_PASSWORD"]	no value
_SERVER["AUTH_USER"]	no value
_SERVER["CERT_COOKIE"]	no value
_SERVER["CERT_FLAGS"]	no value
_SERVER["CERT_ISSUER"]	no value
_SERVER["CERT_SERIALNUMBER"]	no value
_SERVER["CERT_SUBJECT"]	no value
_SERVER["CONTENT_LENGTH"]	0
_SERVER["CONTENT_TYPE"]	no value
_SERVER["GATEWAY_INTERFACE"]	CGI/1.1
_SERVER["HTTPS"]	off
_SERVER["HTTPS_KEYSIZE"]	no value
_SERVER["HTTPS_SECRETKEYSIZE"]	no value
_SERVER["HTTPS_SERVER_ISSUER"]	no value
_SERVER["HTTPS_SERVER_SUBJECT"]	no value
_SERVER["INSTANCE_ID"]	7466002
_SERVER["INSTANCE_META_PATH"]	/LM/W3SVC/7466002
_SERVER["LOCAL_ADDR"]	88.208.252.132
_SERVER["LOGON_USER"]	no value
_SERVER["PATH_TRANSLATED"]	E:\Domains\w\mydomain.co.uk\user\htdocs\testing.php
_SERVER["QUERY_STRING"]	no value
_SERVER["REMOTE_ADDR"]	86.3.55.190
_SERVER["REMOTE_HOST"]	86.3.55.190
_SERVER["REMOTE_PORT"]	65235
_SERVER["REMOTE_USER"]	no value
_SERVER["REQUEST_METHOD"]	GET
_SERVER["SCRIPT_NAME"]	/testing.php
_SERVER["SERVER_NAME"]	http://www.mydomain.co.uk
_SERVER["SERVER_PORT"]	80
_SERVER["SERVER_PORT_SECURE"]	0
_SERVER["SERVER_PROTOCOL"]	HTTP/1.1
_SERVER["SERVER_SOFTWARE"]	Microsoft-IIS/7.0
_SERVER["URL"]	/testing.php
_SERVER["ORIG_PATH_INFO"]	/testing.php
_SERVER["PHP_SELF"]	/testing.php
_SERVER["REQUEST_TIME"]	1280593701
_SERVER["REQUEST_TIME"]	1280593701
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by jraede »

Seems to me like you should rethink your host if they're going to be dicks about it. I honestly have no idea, I'm just going off what I read in that article I posted...it's most definitely not a problem in your code, that is if you did narrow it down to just those lines without missing something else. So I would try telling that to your hosting company, showing them the code that is causing the error (if they have any brains at all they will not try to tell you it's your code), and see what they can do. If you already tried that, I think you're out of luck. I'm stumped.
Post Reply