The specified CGI application misbehaved;

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

Post Reply
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

The specified CGI application misbehaved;

Post by NoReason »

The specified CGI application misbehaved by not returning a complete set of HTTP headers.

Running IIS:5
PHP4.3.3 (php.exe)

1) yes the page exists, using header('Location: http://www.mywebsite.com/');
2) yes I have tried header('Location: http://www.mywebsite.com/index.php');
3)yes check to see if file exists is checked, and not it does not fix the issue.
4) this problem only exists when using the EXE, not when using the isapi dll.

For what I read on teh release notes of 4.3.3 this issue should have been fixed, but I suppose since I am still using IIS the devs did not account for this.

Its very simple, page sends info to proccessing page, it then header() redirects back to the main site.. If I refresh the page all is well, all information was passed back, no data lose, session information intact, all works with in specified parameters... All that is except for the redirect.. and YES I can duplicate it.

I wold love to discover what the hell is going on here.. it works with no errors and no modifications to the code in redhat.. so it MUST be a IIS thing..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

php.ini wrote:; cgi.rfc2616_headers configuration option tells PHP what type of headers to
; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
; is supported by Apache. When this option is set to 1 PHP will send
; RFC2616 compliant header.
; Set to 1 if running under IIS. Default is zero.
;cgi.rfc2616_headers = 0
did you change that?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

What version of PHP, the CLI or the CGI? It must be the CGI version in order to return the headers the webserver needs..

A quickfix is to add this to the top of your script:

echo "Content-Type: text/html\r\n\r\n";

but it wouldnt work very well if your script uses the header() function for other stuff, and it wont work when the script is used with another mod_php or cgi-php setup..
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

heh, Volka is a few seconds ahead of me in everything today :D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

must be my lucky day :-]
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

Yup yup...I managed to see that during my initial INI scouring.

It didnt change the behaviour.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

but you should if you use IIS, as mentioned by the comment. The default is cgi.rfc2616_headers=0 but you need

Code: Select all

cgi.rfc2616_headers = 1
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

Well and good then, I leave it as it is.. But the fact still remains that even after all those modifications, the error still exists while using the CGI version on php.. (php.exe) but not in ISAPI.

I can use ISAPI, however the lack of error reporting sux.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The specified CGI application misbehaved by not returning a complete set of HTTP headers.
That's IIS's default 'page not found', ie. 404 error for missing PHP scripts. To check whether that is the problem, start up Internet Services Manager, right click on your website in the list, select properties then the Home Directory tab, click configuration then select the PHP extension from the list and click edit. Then ensure that the 'Check file exists' check box is ticked and OK everything. You should now get a proper 404 if the PHP page is missing.

Mac
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

3)yes check to see if file exists is checked, and not it does not fix the issue.
Please note my origanal post :)

And with that box checked there is no 404 page... as a matter of fact there should BE no 404 or any nother error page for that matter.. The page DOES exist, its the main index.php that is begin refrenced.

And note, the script works 100% in redhat.
And works with no errors when using the ISAPI dll ..
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Sorry missed that :oops:, that'll teach me to read posts better.

Have you tried messing with the header() statement, you know, removing the space between Location and the URL? Shouldn't make a difference but you never know. Does a relative URL in the redirect do anything?

Mac
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

Modifiing the header statement does nothing.

Im sorry I dont know what you mean by "a relitive URL".
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

By relative I mean, instead of the absolute URL, e.g. http://www.mywebsite.com/index.php, you use the relative path to the page. So if for instance you were in a folder one up from the root directory, you would do:

Code: Select all

header('Location: ../index.php');
This works fine using PHP 4.2 on IIS 4 and PHP 4.3.1 on IIS 5 (both on Win 2k).

Are you sending any other headers? Are you setting any cookies before doing the redirect?

Mac
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

1) No additional Headers are begin sent.
2) No cookies are begin sent
3) Using the relitive path presents the same issue.
NoReason
Forum Commoner
Posts: 51
Joined: Tue Sep 10, 2002 6:19 pm

Post by NoReason »

Just whant to make sure the no one has any idea what is happening.. ?
Post Reply