+ Reply to Thread
Results 1 to 11 of 11

Thread: Jump Script Parse Error

  1. #1
    DNF Member
    Last Activity 03-07-2010 12:33 PM
    gawnd's Avatar

    Join Date
    Jul 2007
    Location
    United States
    Country
    Posts
    555
    DNF$
    1,785
    Blog Entries
    1
    Trader Rating: 22 reviews

    Jump Script Parse Error

    I am going crazy trying to get a simple jump script setup for affiliate links.

    I keep getting the following error.
    PHP Parse error: parse error, unexpected T_STRING in Line 2

    on the following script:

    <?PHP
    if ($o == "l1") {$link = "http://www.example.com";} // Default link
    if ($o == "l2") {$link = "http://www.anotherexample.com";}
    header("Location: $link"); // Jump to the hiddden URL above
    exit();
    ?>
    Anyone have any idea what could be wrong here?


  2. #2
    www.LOL.biz
    Last Activity Today 06:25 AM
    Bender's Avatar

    Join Date
    Apr 2004
    Location
    .ro
    Country
    Posts
    1,882
    DNF$
    5,749
    Trader Rating: 14 reviews
    -where is $o defined?
    Code:
    <?
    switch($o)
    {
    case "l2":
    $redirect="http://www.link2.com";
    break;
    case "l1":
    $redirect="http://www.link1.com";
    break;
    }
    header("Location: ".$redirect);
    ?>
    
    Last edited by Bender; 10-26-2007 at 11:35 AM.


  3. #3
    DNF Member
    Last Activity 03-07-2010 12:33 PM
    gawnd's Avatar

    Join Date
    Jul 2007
    Location
    United States
    Country
    Posts
    555
    DNF$
    1,785
    Blog Entries
    1
    Trader Rating: 22 reviews
    I have my links built like this:

    http://www.example.com/jumpscript.php?o=l1
    http://www.example.com/jumpscript.php?o=l2

    I tried the above script and got the same results. Even with a simple header redirect without variables, I'm getting parse errors. Could there be a server setting, htaccess or php.ini that I'm missing?


  4. #4
    Last Activity Today 04:16 AM
    Johnn</a><br /><span class='glow_008000'>NameIntell.com</span><a href='http://www.dnforum.com/f181/jump-script-parse-error-thread-257024.html#'>'s Avatar

    Join Date
    Apr 2004
    Location
    Pennsylvania
    Country
    Posts
    12,139
    DNF$
    12,243
    Trader Rating: 338 reviews
    Missing ";" at the end of line 2 and 3?


  5. #5
    www.LOL.biz
    Last Activity Today 06:25 AM
    Bender's Avatar

    Join Date
    Apr 2004
    Location
    .ro
    Country
    Posts
    1,882
    DNF$
    5,749
    Trader Rating: 14 reviews
    Code:
    <?
    switch($_GET['o'])
    {
    case "l2":
    $redirect="http://www.link2.com";
    break;
    case "l1":
    $redirect="http://www.link1.com";
    break;
    }
    header("Location: ".$redirect);
    ?>
    


  6. #6
    DNF Member
    Last Activity 03-07-2010 12:33 PM
    gawnd's Avatar

    Join Date
    Jul 2007
    Location
    United States
    Country
    Posts
    555
    DNF$
    1,785
    Blog Entries
    1
    Trader Rating: 22 reviews
    bender - that worked out. thanks so much.
    i had a combination of issues - one, was editing in wordpad for some reason and it was throwing in odd formatting.

    once i cleared that up, it was clear that the variable wasn't being defined and your new script solved that.

    thanks again.


  7. #7
    www.LOL.biz
    Last Activity Today 06:25 AM
    Bender's Avatar

    Join Date
    Apr 2004
    Location
    .ro
    Country
    Posts
    1,882
    DNF$
    5,749
    Trader Rating: 14 reviews
    glad to help whenever I can.


  8. #8
    Last Activity Today 04:16 AM
    Johnn</a><br /><span class='glow_008000'>NameIntell.com</span><a href='http://www.dnforum.com/f181/jump-script-parse-error-thread-257024.html#'>'s Avatar

    Join Date
    Apr 2004
    Location
    Pennsylvania
    Country
    Posts
    12,139
    DNF$
    12,243
    Trader Rating: 338 reviews
    Good job Bender.

    50 $F donated to your account.


  9. #9
    DNF Member
    Last Activity 03-07-2010 12:33 PM
    gawnd's Avatar

    Join Date
    Jul 2007
    Location
    United States
    Country
    Posts
    555
    DNF$
    1,785
    Blog Entries
    1
    Trader Rating: 22 reviews
    if you look online the first script i posted seems to be the norm. any specific reason the variable o wasn't being defined in my version?

    i'm still a copy and paste php hack, but slowly learning.


  10. #10
    www.LOL.biz
    Last Activity Today 06:25 AM
    Bender's Avatar

    Join Date
    Apr 2004
    Location
    .ro
    Country
    Posts
    1,882
    DNF$
    5,749
    Trader Rating: 14 reviews
    the $o variable wasn't defined - you expected to be automatically extracted from the $_GET variables, but this is no longer the case in newer PHP versions(security reasons)
    you could use an extract($_GET) but this NOT recommended


  11. #11
    Platinum Lifetime Member
    Last Activity 02-03-2009 07:34 PM

    Join Date
    Nov 2006
    Location
    USA
    Country
    Posts
    493
    Trader Rating: 10 reviews
    You could also do something like...

    Code:
    function pop_vals($associative_array) {
     foreach ($associative_array as $key=>$val) {
      eval('$'.$key.' = "'.$val.'";");
     }
    }
    
    pop_vals($_REQUEST);
    
    // $o should now be defined
    
    I do NOT recommend this, though, as someone could run...

    YOURURL?o=|1&SOMEREMOTECOMMANDSHERE

    Jason


+ Reply to Thread

Bookmarks

Posting Permissions

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