Simple php redirect problem

by 10 replies
12
Hi Guys

I am trying to do a simple redirect which is not playing the game.

I have a landing page which has a few links to some .php files, which i have installed linking script from tracking202. I have only got the <?php code ?> in the php files.

I keep getting
"Warning: Cannot modify header information - headers already sent by etc etc."

I have tried putting the .php files in the root directory,same directory and in a folder of its own, but still get the problem.

This should be fairly straight forward, but it has got me stumped.

Any help would be great.

Cheers

David Mee
#programming #php #problem #redirect #simple
  • Is there a space or hard return at the top of the PHP file? If so, delete/remove it.
  • Yes, that message means that the script is outputting something before the re-direct occurs. Can you paste the actual script.. or some of it in here?
  • is there any "echo" or "print" statement before the redirection?
    • [1] reply
    • ya, paste the code, should be an easy fix.
      • [1] reply
  • Make sure there is no HTML above that script. you can also put the redirect code in an if statement.

    So: if(5+5=10)
    {
    header('location: '.$tracking202outbound);
    }
  • I had encountered this type of problem. This can occure if there is some meta information is added into your file. Like you created a text file first n renamed to php. To resolve this issue, copy content of your file, open notepad, paste content n then save file "filename.php" with quotes.

    This should solve your problem.
    • [1] reply
    • Thanks for your input guys

      I created brand new php files with notepad, put "" around the filename, and left no spaces between the lines of code and it worked!!

      I had created the first php files from in expression web, something about that combination didn't work.

      Cheers

      Dave
      • [1] reply
  • It needs to be done before anything is outputted to the browser so before the <html> tag

Next Topics on Trending Feed