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

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

Cheers for being a second set of eyes. Yeah the hosting company basically said it was a problem with my code. It's really stupid. Going to see if I can get my money back although I doubt I would.

Oh to have a dedicated server again (well being able to afford 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 »

Rackmounted.com had a deal for a while for $50/month for a low-end dedicated...not sure if they still have it but you should check it out.
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 from the UK so low end dedicated's are about £60 ($100ish) a month.

I'll stick with the tried and tested method of "Code and Prey" ie, make it on local and then hope it works everywhere else.

I've only been with that host for 4 days so I'm well within my rights by UK law to cancel. Over here we have something called a 7 day cooling off period which means you can return/cancel contracts within that time.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

You are using Internet Explorer, aren't you?

IE is famous for it's generic HTTP 500 response. In any other browser, even if it received the HTTP 500 response, it would still show the page if it was provided. The 500 response means that an error occurred, regardless of the severity. In your case, the error is an undefined index. You will see this in your error.log (or error_log.txt, depends on the host) file on the server.

The solution? Fix the problem or tell PHP to stop reporting it. To fix it, always check that a variable has been set before using it with isset() or empty(). To tell PHP to stop reporting it, utilize the error_reporting() function.
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

Actually I'm using, Internet Explorer, Chrome, Firefox, Opera and Safari. Happens in all of them.

I've used the following so get shouldnt even be executed and it still errors.

Code: Select all

$var = false;
	if($var == true)
	{
		if(empty($hello){
			$hello = $_GET['hello'];
			echo $hello;
		}
	}
	else echo $var;
The error logs are set to their most basic on the server setup. It shows that an internal 500 has occurred but does not state the cause. Also I cannot use error reporting function because of this issue as no page will be displayed.
Last edited by PeteA on Sun Aug 01, 2010 11:07 am, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

PeteA wrote:I've used the following so get shouldnt even be executed and it still errors.

Code: Select all

$var = false;
	if($var = true)
	{
...
"$var = true" and "$var == true" are not the same thing. You are setting it's value to true, then checking if THAT value is true, which it now is.

Maybe you should refresh your memory on logical operators.
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

typo, and it does't work. I'm just going to wait until tomorrow (monday) and get my money back. Already tested on a few other hosts and not had a single problem. Oh well theres always one.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

PeteA wrote:

Code: Select all

...
		if(empty($hello){
...
There's also a typo here. But if you're sure it's your host's fault...
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 retyped it into the browser. Right copy and paste time.

Code: Select all

<?php
	
	$var = 'false';
	
	if($var == 'true')
	{
		if(empty($hello)){
			$hello = $_GET['hello'];
			echo $hello;
		}
	}
	else echo $var;
?>
Still 500, I'm thinking they have something seriously wrong. Just installed joomla and that errors as well, so I'm thinking they have a bad install (not that their willing to do anything about it) or even look at it for that matter.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

Strange. Maybe it is your host. But, if your website is the only one experiencing this issue, then it could be something else...

Have you looked at the error log file, yet?
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, as I said in my previous post they're set to their most basic, so all it shows is the page and the error code.

I spoke to someone higher up in the chain a few min ago and have been assured they'll transfer me to a new server and test it before they do.

She did seem pretty knowledgeable and did actually say it might be best to use linux as they've had issue with Windows IIS Servers in the past. Only using one because I need ASP.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

The error log only shows error codes? And nothing in the error log gives a hint as to what is going wrong? There's no difficulties with .htaccess or with PHP itself?
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

well its windows so there's no htaccess file.

2010-08-01 16:20:58 GET /test.php 500

That's all I get, when I spoke to someone yesterday they said they stripped them down for security reasons. More like saving space, also being on a windows server php errors give 500 instead of line/location/reason.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by superdezign »

Oh. I totally see what you are talking about.

I'd switch. Firstly, I prefer hosts that trust me with my own debugging information. Secondly, I wouldn't want my site to reside on a Windows server unless it absolutely had to. :P
PeteA
Forum Newbie
Posts: 16
Joined: Fri Jul 30, 2010 4:58 pm

Re: $_GET and $_REQUEST causing Internal Server Errors

Post by PeteA »

Yeah, I absolutely have to unfortunately (well for this site). Theres some .NET framework that's needed. Personally I could rewrite it in Java in about a week but I'd have to code and maintain it on my own time. Cross ASP and PHP is a pain in the proverbial.

I'm going to see if I can get my money back anyhow.

Cheers for the help, hopefully I'll get to take a look at their PHP ini
Post Reply