Simple php redirect problem

10 replies
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
#php #problem #redirect #simple
  • Profile picture of the author pbarnhart
    Is there a space or hard return at the top of the PHP file? If so, delete/remove it.
    {{ DiscussionBoard.errors[2398944].message }}
  • Profile picture of the author AndyBlackSEO
    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?
    Signature
    [FREE SEO TOOL] Build 29 Effective, High Authority Backlinks that Will Increase Your Google Rankings in 2020... CLICK HERE ...
    ... Instant backlinks that can get you results within 24-72hrs.
    {{ DiscussionBoard.errors[2398970].message }}
  • Profile picture of the author Shounak Gupte
    is there any "echo" or "print" statement before the redirection?
    Signature
    Looking for a quality but affordable graphic designer to partner with. To express your interest PM me with some samples.
    {{ DiscussionBoard.errors[2399014].message }}
    • Profile picture of the author CarloD.
      ya, paste the code, should be an easy fix.
      Signature

      {{ DiscussionBoard.errors[2399127].message }}
      • Profile picture of the author davidmeeonline
        Thanks Guys

        This is the code which I cut and pasted from tracking202. Just changed the details a bit.

        <?php

        // -------------------------------------------------------------------
        //
        // Tracking202 PHP Redirection, created on Wed Jul, 2010
        //
        // This PHP code is to be used for the following setup:
        // Offer1 on w.Offer1.com/Offer1page1.htm
        //
        // -------------------------------------------------------------------

        $tracking202outbound = '://redirect.tracking202.com/off/xxxxxxx/'.$_COOKIE['tracking202pci'];

        header('location: '.$tracking202outbound);

        ?>

        Had to remove (http) and www to be able to post it.
        Thanks again

        Dave
        {{ DiscussionBoard.errors[2399450].message }}
  • Profile picture of the author ImHot
    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);
    }
    {{ DiscussionBoard.errors[2402238].message }}
  • Profile picture of the author mihir
    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.
    {{ DiscussionBoard.errors[2403060].message }}
    • Profile picture of the author davidmeeonline
      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
      {{ DiscussionBoard.errors[2403376].message }}
      • Profile picture of the author CarloD.
        Encoding may have been wrong on the file, that can cause some issues,
        Signature

        {{ DiscussionBoard.errors[2403609].message }}
  • Profile picture of the author bugbuguk
    It needs to be done before anything is outputted to the browser so before the <html> tag
    Signature

    Google News Press Releases , PM For Details :)

    {{ DiscussionBoard.errors[2421098].message }}

Trending Topics