Results 1 to 2 of 2

Thread: Question about Error message

  1. #1
    Join Date
    Jul 2007
    Posts
    32
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Question about Error message

    I found this affilate link masking script and it works:

    Code:
    <?php
    $v = $_GET['v'];
    // In case someone calls naked php file
    if ($v == '') {$link = 'http://example.com/';}
     
    // Add as many as links in below format. Each in a new line.
    if ($v == 'product1') {$link = 'http://example1.com/';}
    if ($v == 'product2') {$link = 'http://example2.com/';}
    if ($v == 'product3') {$link = 'http://example3.com/';}
     
    // Don't change anything below this line.
    header("Location: $link") ;
    exit();
    ?>
    But i see in the server error log that it gives folling error everytime the link is clicked: Undefined variable: link in /home/../public_html/..com/go.php on line 13.
    Can someone tell me why it makes this error? Because the script works

    regards

  2. #2
    Join Date
    Jan 2015
    Posts
    76
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Default

    The only time you should see an undefined $link error is if the page gets requested with a $_GET['v'] value that doesn't exist in the comparisons in the code. When this is the case, $link won't exist and the header("Location: ") will redirect to the go.php page and it will appear that nothing happened. Depending on the browser you are using, you should either get a blank page or a browser error telling you that the page isn't redirecting properly. If the page gets requested with either no $_GET['v'] parameter or there is one but the value is empty, the 1st default URL will be used.

    Is there any chance that the URLs this script redirects to are making a http request back to the go.php page with a $_GET['v'] value that doesn't match one of the choices? This is the only thing that I can think of that would cause the script to appear to work (redirects to the correct URL) and causes an undefined $link error to be logged.

    You can either check the web server's access log or add some code to log request information in the go.php script to see what requests it is receiving.

Similar Threads

  1. Question about an error message on contact form
    By windbrand in forum JavaScript
    Replies: 1
    Last Post: 01-05-2012, 05:42 PM
  2. Error Message in 3d spinning message
    By drgsb in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 05-24-2009, 06:36 AM
  3. XML error message
    By jendelaniaga in forum Dynamic Drive scripts help
    Replies: 25
    Last Post: 07-26-2008, 05:01 AM
  4. XML error message
    By kalxen in forum HTML
    Replies: 2
    Last Post: 04-10-2008, 02:04 PM
  5. Error message...
    By confusio in forum PHP
    Replies: 4
    Last Post: 07-08-2006, 03:19 AM

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
  •