#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    I have a linking script, and on my index page i have some code so that only one IP address can vote for the same referral once per day, but it alwas resets the hits to 1 every time a hit comes in....so no matter how many are sent, it only ever shows one. the code is as follows and i can't figure out what is wrong, help would be much apprechiated:

    if(!empty($ref)){
    mysql_connect('localhost','username','pass') or die("Unable to connect to database");
    mysql_select_db(mp3findit) or die("unable to select db");

    $ip = $REMOTE_ADDR;
    $result = mysql_db_query(mp3findit,"SELECT * from refips where ip = '$ip'");
    $num = mysql_num_rows($result);

    if($num == ''){
    $res2 = mysql_db_query(mp3findit,"SELECT refcount from refcount where id = $ref");
    while($row=mysql_fetch_object($res2)){
    $score = $row->refcount;
    $score++;
    mysql_db_query(mp3findit,"UPDATE reflink set refcount = $score where id = $ref");
    mysql_db_query(mp3findit,"INSERT into refips values('$ref','$ip')");
    echo "<!----Ref ID: $ref , Referrals: $score referral went in---->";
    }
    }
    else {
    $refcount = 0;
    while($row=mysql_fetch_object($result)){
    if($row->id == $ref){
    $refcount++;
    }
    }
    if($refcount == '0'){
    $res2 = mysql_db_query(mp3findit,"SELECT refcount from refcount where id = $ref");
    while($row=mysql_fetch_object($res2)){
    $score = $row->score;
    $score++;
    mysql_db_query(mp3findit,"UPDATE refcount set refcount = $score where id = $ref");
    mysql_db_query(mp3findit,"INSERT into refips values('$ref','$ip')");
    echo "<!-----Ref ID: $ref , Referrals: $score referral went in, this person has visited b4----->";
    }
    }
    else { echo "<!------referral didnt go in, already been referred today----->"; }
    }
    }

    Thanks,
    Scott Lee

    [This message has been edited by mp3findit (edited September 02, 2000).]
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Seattle, WA,USA
    Posts
    84
    Rep Power
    15
    Do you get an error? I've had similar problems.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Quispamsis, NB, Canada
    Posts
    49
    Rep Power
    15
    No, I don't get an error, but the hits will never go above 1, its like it erases the hits and starts new with every referral....i dont know what the problem is...
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Seattle, WA,USA
    Posts
    84
    Rep Power
    15
    Why don't you try

    $score + 1;

    I think ++ means add one after it's executed.

    [This message has been edited by jgagner (edited September 02, 2000).]

Similar Threads

  1. simple form, simple trigger, whats wrong ??
    By zishto in forum Oracle Development
    Replies: 3
    Last Post: January 12th, 2004, 01:25 PM
  2. what is wrong with this code ????
    By fule in forum Database Management
    Replies: 1
    Last Post: November 20th, 2003, 01:24 AM
  3. *sigh*
    By vb.net in forum Dev Shed Lounge
    Replies: 45
    Last Post: November 9th, 2003, 07:52 PM
  4. offsetHeight returning the wrong height
    By Tobbe in forum HTML Programming
    Replies: 10
    Last Post: October 19th, 2003, 08:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo