SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    HAHA!
    Join Date
    Mar 2006
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with simple php clicks script

    This is just a very simple script to assign affiliate urls to different ids:

    Code:
    <? $ID = intval($_GET["ID"]);
    switch($ID)
    {
    case 1: // Deal/Location B
    $url = "http://www.affsite.com/?BTag=blah";
    break;
    
    case 2: // Deal/Location B
    
    $url = "";
    break;
    
    default: // If there is an error, send them somewhere else
    $url = "http://www.affsite2.com/mBannerClick.aspx?bannerid=blah";
    break;
    }
    header("Location: $url");
    ?>
    Now I saved this in a clicks.php and when I go to xwww.mysite.com/clicks.php?id=1 I get an error complaining about the colon on line 17 (after location). I don't see what the problem with that colon is. I removed the space between the colon and the url variable and now I don't get an error but I am redirected to the default url. Can anyone see where I've gone wrong?
    Cheap web hosting directory listing the cheapest web hosting

    Submit articles to an article directory

  2. #2
    SitePoint Zealot glowdot's Avatar
    Join Date
    Jun 2007
    Location
    Santa Monica, CA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sometimes strings in header calls can be picky. Have you tried:

    Code:
    header("Location:". $url);
    instead?

    I get no error running that code, though. I'm almost certain it has something to do with the value of $_GET['id'].
    Advertise on Glowfoto
    banners as low as $25/month, text ads $10/month
    Share 10 million impressions per month!

  3. #3
    HAHA!
    Join Date
    Mar 2006
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unfortunately it still redirects me to the default value. For some reason the script doesn't seem to be able to recognise ID 1. I even stripped out the default but all I got when I clicked was a blank page.
    Cheap web hosting directory listing the cheapest web hosting

    Submit articles to an article directory

  4. #4
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is definitely a problem with $_GET[ID]. First I would make ID lowercase. Show us some of your ID values and the output you get.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  5. #5
    HAHA!
    Join Date
    Mar 2006
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eureka!

    id in lower case did the trick. Thanks a lot!
    Cheap web hosting directory listing the cheapest web hosting

    Submit articles to an article directory

  6. #6
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed


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
  •