Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and function header

Status
Not open for further replies.

Artur

Programmer
Mar 28, 2001
11
PT
I am using php on windows 2000, and IS. when i use the function "Header()" to redirect sometimes, not all the time, it give me an error.

I will give an example:

header("Location: alertas.php?erro=3&ti&tip=$tip");

When i execute the script, in the browser appears this error :

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are


I hope someone can help me. Thank you!!
 
use the following header instead:

header($location){
...some code...
}

to call the header use:

header("alertas.php?erro=3&tip='$tip'");

mind the '' around the $tip variable..

Hope that did it..
 
I did nnot understand how to use the other header.

i did no work using

header("alertas.php?erro=3&tip='$tip'");


 
- the function looks like this, right:

function Header($location)
//$location is the var. that cathes the location string
{
//...put some code here to redirect the user...
}

- you call the function with this:

Header("alertas.php?erro=3&tip='$tip'")
 
Why would you have to make a function called Header()? That's kind of confusing, when php has a build-in function called header().

Artur's method was correct, except that the word 'header' is capitalized.

Try it as:

header("location: alertas.php?erro=3&ti&tip=$tip");

If it still doesn't work, try it with the full path (
It also looks like you might have an error in your query string. "?erro=3&ti&tip=$tip". You are creating a key "ti" without a value. Just check it out to make sure.
 
Actually, (after checking the PHP site) it looks like it doesn't matter whether "location" is capitalized or not. You probably have a configuration problem with Win2000 and the CGI version of PHP.

Try creating a PHP file with the contents <? phpinfo(); ?>, and view that file as a web page. It should list everything enabled in PHP on your system. If you have any questions, you could post some of that here for us to look at. (Before doing that, please edit any location-specific or domain-specific information--don't trust us just because we mean well ;-))
 
Thank you all.

I have already try everthig that was said here, but nothing work.
I try everything on the confuguration of the IS, but nothing work.
I try in others computers and did not work.

I know peoplo with the same proble


 
Are the people with the same problem using IIS on Windows servers or any using Apache with Linux/Unix?

I have never had a problem with header functions on my Unix servers with PHP. I'm just curious if there is some reason IIS gives problems with it.

It looks to me like the problem might be tied in to the fact that most Windows/PHP installs use the CGI method instead of the ISAPI method. Maybe somehow the header requests get mangled going through the CGI interpreter.

Also, (I'm sure you know) header requests must be the first thing loaded to the browser in any request, before any other data is output. Also--hopefully obvious--you don't really wanting to output anything to the browser *after* the header request. It really must be in it's own logical code block. Do you have the exit() statement right after the block that runs your header request?
 
I have become a member.

First: Until now, i have always use php in linux and apache. I have never got this error in linux, only now in windows.

Second : I am aware of the use of headers. I have 100% certain that i am not using wrong the header function.


P.S. : Sorry for my English. Artur Carvalho
ajc@mni.pt
Portugal
 
Sim, senhor :)

Then, I guess we have decided that the problem is with PHP/IIS. Maybe the HTTP headers are disabled, either somewhere in the IIS settings, or in the php.ini file. PHP allows the administrator to specifically disable functions by name.
 
Do you speak portuguese?
That's nice.


Thank you for your reply.


I am afraid that the proble is with IS. But i have already spend hours modifying the configuration of it, and the error still there.

But i will not give up. I will find the problem Artur Carvalho
ajc@mni.pt
Portugal
 
Hablo espanol, pero entiendo un poco de Portuguese.

Do you have PHP configured as a CGI program, or as ISAPI redirected (like ASP)?
 
I have like a CGI.

How do i configure to be ISAPI. What is the ISAPI, i realy don´t know Artur Carvalho
ajc@mni.pt
Portugal
 
I don't know if u're using the CGI mode, I'm using the Apache/ISAPI mode and your script does run good. I Use PHPTriad in Win2000 Adv.
 
I have now php in ISAPI. But the problem still there
Artur Carvalho
ajc@mni.pt
Portugal
 
As I said before, try showing us the output from phpinfo(), after removing the IP address and hostname info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top