Forum Moderators: coopster

Message Too Old, No Replies

Header problem - again...

headers already sent

         

lorax

4:34 pm on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I understand the basics of headers but here's a problem that doesn't fit with what I thought I knew.

Page 1: 2 forms with 1 select box each. The option values are page names (page1.php). Javascript is used to submit the form using onChange event. Form actions point to a seperate page that has the following code:

Page 2:
<?php
header("Location: /dir1/dir2/$pn.php");
exit;
?>

where $pn is the value of the <option> selected.

There's no HTML on this page.

So why am I getting "Headers already sent"?

Nick_W

4:38 pm on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it' page 2 that's throwing up the error, is that really how it looks or is there any include/requires' in that file?

Sometime having a blank line after?> at the end of an include will cause that kind of problem...

Nick

lorax

4:46 pm on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



DOH!

I found the error - a single space in front of my <?php - well at least I only spent 30 minutes on this one.

Thanks Nick.

Nick_W

4:49 pm on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anytime, I've spent hour upon hour pouring over code only to find similar daft mistakes. It's those little ones that are the toughest... ;-)

Nick