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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

header() problem?? 1

Status
Not open for further replies.

Elliott3

Programmer
Joined
Sep 5, 2002
Messages
347
Location
CA
Hi,

Is there anything strange I should know about header()? I have the line:
header("Location: thanks.php?action=reg");
in my code. No parse errors are reported and everything runs ok until this line? if i comment it out, there is no issue at all but if i leave that line in, my browser complains about there being a syntax error.

Any ieas at all?

CES
 
Also,

It does actually make it to the next page...i just get the message do you wish to debug yes/no?

I am at a loss here?

CES
 
Yes, use of a Location header will immediately take the browser to the new page.

Is your script producing output as well as invoking header()? It sounds to me like your header invokation is mixed up with some JavaScript output or something.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thank you very much!

That is what I was just looking into. It was exactly what you said...i had a javascript function before the header() and there can be absolutely no output prior to the header() call...right?

CES
 
I have the same problem on another page but I don't seem to have any output before the header()....any ideas?

CES
 
sorry...the message for this page is

Cannot modify header information - headers already sent by

CES
 
ONE SPACE!!

I found it...thanks again!!

To any others i had..

<?php require_once('Include/dbconn.php'); ?>
<?php ...

i know i didn't have to right the require_once on its own but i am.

Anyhow, there was one space at the end of that line(ln:1)...only one. Just a note to all others new to php.

Thanks sleipnir214

CES

 
The curse of the whitespace !!,
anotehr thing if you use header always make the page name is the entire HTTP:// style address. If you look at the online docs at the php site(and in the pdf) it tells you to do this in the reader comments. A real pain but there you go. It wouldn't work for me using xitami web server, i set up a function that wrapped the page and just prefexied the current server name etc. An example is with the documentation. It's all because of the http 1.1 specification.
The error about headers already being sent can be difficult to code around I guess. I've never used the facility but I think you can buffer up the output and php will detect headers and cookies and stuff and put them in the correct place for you.

regards

Kevin
 
cool...thanks for the tip

CES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top