Trying to get PHP redirect to work but failing miserably

Discussion in 'PHP' started by tramore35, Aug 17, 2008.

  1. #1
    I absolutely suck at coding so I have been surfing the net to find code to mask my affiliate links. I have done every step I find that I need to do but it doesn't work. Could someone please review this and tell me what I am doing wrong.

    In my publichtml file I have a file named index.php which contains my landing page.

    I have another page titled go.php. Inside this page I have this code:

    <?php
    header( ‘Location: http://myaffiliatelink.com/1g1Xz’ ) ;
    ?>

    In my index.php file when I want to link to my affiliate page i type this:

    <a href="http://mysite/go.php">click here</a>

    every time I click on the click here link I get this error code:

    Parse error: syntax error, unexpected ':' in /home/mysite/public_html/go.php on line 2

    I would appreciate any help you could give me.
    Thanks.
     
    tramore35, Aug 17, 2008 IP
  2. pluswebdev

    pluswebdev Banned

    Messages:
    205
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this:
    
    <?php
    $redirect_url = 'http://x.azjmp.com/1g1Xz';
    echo "<meta http-equiv=\"REFRESH\" content=\"0;url=$redirect_url\">";
    @header("Location: $redirect_url");
    ?>
    
    PHP:
    Also, the wrong part in your code is:
    <?php
    header( ‘Location: http://x.azjmp.com/1g1Xz’ ) ;
    ?>

    it should be
    <?php
    header( 'Location: http://x.azjmp.com/1g1Xz' ) ;
    ?>
    Note the right syntax of quote character.
     
    pluswebdev, Aug 17, 2008 IP
  3. tramore35

    tramore35 Active Member

    Messages:
    397
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for responding. I tried that code and now I don't get an error message but I get a blank page. It does not redirect to my affiliate page.

    This is driving me absolutely nuts.
     
    tramore35, Aug 17, 2008 IP
  4. pluswebdev

    pluswebdev Banned

    Messages:
    205
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it should work in %100
    can post the url of your go.php ?
     
    pluswebdev, Aug 17, 2008 IP
  5. tramore35

    tramore35 Active Member

    Messages:
    397
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    I don't really want to post the site here. I will send you a pm. Thanks for all your help.
     
    tramore35, Aug 17, 2008 IP
  6. pluswebdev

    pluswebdev Banned

    Messages:
    205
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,
    use the full url with http:// in front of , not just x.azjmp.com/1g1Xz
     
    pluswebdev, Aug 17, 2008 IP
  7. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Hi,

    Use this function

    <?php
    function FunJavaScriptRedirection($url)
    {?>
    <script type=”text/javascript”>
    <!–
    window.location = “<?=$url?>”
    //–>
    </script>
    <?}
    FunJavaScriptRedirection(”http://x.azjmp.com/1g1Xz”);
    ?>
     
    nice.wallpapers, Aug 17, 2008 IP