...

View Full Version : header already sent



Switch17
04-01-2003, 01:53 AM
Hi

I'm trying to redirct to another file, which is using an include statement as follows:

require 'file_defs.php';
header("location: http://www.freedffl.com/football/0302_standings.php");
exit();


I keep getting a header already called error, and reading here I've learned it has to do with the include. If I'm correct, during the redirect, the header is first opening up via the file_defs.php, and then trying to open a second time during the standings file.

Is there a way around this?

x_goose_x
04-01-2003, 02:50 AM
header("location: http://www.freedffl.com/football/0302_standings.php");


and make sure there is no text before you <?php
,not even spaces.

Switch17
04-01-2003, 03:10 AM
I apologize. Your showing the correct url i have. Somewhere in my copy and paste, it got screwed up. I'm gonna edit my original post.

It will redirect fine when I don't add in the include command. But once I add that, I get the header already sent error.

lol..OK, I've tried to correct my original post above to reflect what you typed, as that how I had it anyway, and I actually have that in my post abve. For some reason or other, the board here keeps giving it url tags there in the post.

Spookster
04-01-2003, 03:37 AM
You cannot send anything to the browser before you send a header. You are probably sending something to the browser in your file_defs.php include file.

Switch17
04-01-2003, 03:56 AM
Thats what I kinda thought. The thing is, my file_defs file is just a defining all the files, thus looks a little like this:
$FL[0] = "_standings".$ext."0";
$FL[1] = "_tiebreaker".$ext."1";
$FL[2] = "_allstars".$ext."2";

As far as I can see, there's nothing in the file that is calling to the browser.

I figured once I can get the include to work, I'd go back and change the header(location to the new url.

Is there a work around of any kind. I'm reading up on sorta of doing this witha java script as well, but I believe a server side redirect would be best.

x_goose_x
04-01-2003, 04:00 AM
if that is the case, you can use client side:



print '<script language="javascript" type="text/javascript">\n';
print 'location.replace("http://www.freedffl.com/football/0302_standings.php");\n';
print '</script>';

Spookster
04-01-2003, 06:57 AM
Make sure that that your included file has no spaces before <?php and after ?>. Any spaces there will make the parser go into HTML mode and output those spaces to the browser.

Switch17
04-01-2003, 06:29 PM
Make sure that that your included file has no spaces before <?php and after ?>. Any spaces there will make the parser go into HTML mode and output those spaces to the browser.
Thanks, that looked to be the problem. I had a trailing space after my closing ?>. Took that out, and it seems to be working.

missing-score
04-03-2003, 08:03 PM
You have part of the include file with the variables, but do you need them on the page?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum