Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    header already sent

    Hi

    I'm trying to redirct to another file, which is using an include statement as follows:
    PHP Code:
    require 'file_defs.php';
    header("location: [url]http://www.freedffl.com/football/0302_standings.php[/url]");
    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?
    Last edited by Switch17; 04-01-2003 at 03:21 AM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    header("location: http://www.freedffl.com/football/0302_standings.php"); 
    and make sure there is no text before you <?php
    ,not even spaces.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by Switch17; 04-01-2003 at 03:17 AM.

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    PHP Code:
    $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.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if that is the case, you can use client side:

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

  • #7
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #9
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Am I missing something?

    You have part of the include file with the variables, but do you need them on the page?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •