#1
  1. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,008
    Rep Power
    376

    Headers already sent errro


    Ok I know what the problem is. My question is

    does doing something like

    $variable = "test";

    cause problems with this:

    header('Location:url');
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Only if your code produces errors or warnings, which are then spit to the screen with plaintext headers.

    If you do:

    PHP Code:
    $a = array();

    $b $a['foo']; 
    You will get a warning about the undefined index 'foo'. If your server is set up to broadcast errors to the screen, that error will show up and the headers will be printed for a plaintext/HTML document.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,008
    Rep Power
    376
    thanks. that wasnt the problem i.e. coding error. I did $foo="bar" instead of $foo = "bar" (spaces removed) and it seemed to work :s.
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    Spaces within your PHP code are not sent as output and won't affect headers.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo