SitePoint Sponsor

User Tag List

Results 1 to 19 of 19

Thread: Division?

  1. #1
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm doing a rating script.
    How do I divide numbers? Whereby a variable is assigned to a number, of which they are divided by another variable.

    Also, how to maintain that a user can only vote once?

    thanks
    and sorry about the many posts todae....
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $newnum = $num1 / $num2;

    As for the voting only once thing, you could store the ipnumber along with the vote in the db and then check for the exsiting ip number to be present in the db before putting a new vote in, at least would make sure noone votes from the same computer twice.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    weird..my division is correct..but my script reports a zero division error after a user rates...
    weird

    I store the entire IP? as in the entire length of ip?
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HArd to say without seeing the part of the script that divides. Yes the whole IP number should be something like 207.42.92.105
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Gong!
    Join Date
    May 2000
    Location
    Helsinki, Finland
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp

    As for the voting only once thing, you could store the ipnumber along with the vote in the db and then check for
    It is generally a bad idea to use IP's for user authentication (i.e. to check if they have voted already), since a lot of people are behind NAT nowadays. Like those dial-up's.

  6. #6
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okie.
    It seems there's alot of problem with my mathematical functions

    How do you ADD?

    Thanks
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  7. #7
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you see any problem with this:

    $open_rate = fopen("$dat2/$id.inc", 'w+');
    list ($rate_value, $rate_total) = split ("\|", $open_rate);
    $total_value_rate = $rate + $rate_value;
    $total_total_rate = 1 + $rate_total;
    fwrite($open_rate, "$total_value_rate|$total_total_rate");
    fclose($open_rate);

    ? it doens't seem to be adding
    its just replacing the old values with the new ones
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmahonen,

    How would you make sure that noone votes more than once short of making them log in before voting? Sure you could use sessions but that is only good for one session, and cookies can be disabled
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okie.
    Thanks..I managed to fugure a way round it.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  10. #10
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Location
    Switzerland
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on my rating system, what i do is logging both ip and addresses (like dialup165.sf.aol.com). the ip is used to avoid multiple rating (automatically) and the addresses are used to "manually" track cheaters. it's the best solution i think.

  11. #11
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm..
    I'm current setting cookies to prevent people from voting more than once every 24 hours

    I thik that should be sufficient?
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  12. #12
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd say so - people can't really "spam" a poll if they're limimted to a vote a day - unless the poll gets no votes from almost anyone else.

  13. #13
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YEP..LOL

    Hmm..
    I'm just wondering...
    Whats the statistical reports as to of 100 people, at least how many bothers to fill in a poll?
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  14. #14
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if that kind of information would be readily available, but here's guessing that less than one out of every one-hundered people bother to vote in each poll.

  15. #15
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL!
    Goosh...how do people then get others to vote..hmm..
    pondering.....

    YTou cna't offer an incentives every 7 days?? assuming you have a weekly poll..thats out of the point..haah
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  16. #16
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Incentives? Well, perhaps - but if you were to offer a prize of some sort, people would have to "register" somehow so you would have their contact information on hand assuming they "won."

    You could, I suppose, just offer them access to some special area of the site for voting - they vote, are shown the results, and given a link, but they can "share" the link with others easily I'm sure.

    Polls are best used to gather demographic data most of the time - a significant amount of traffic is required to make them work.

  17. #17
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah..I agree too..

    Do you have polls on your site?
    I'm horribly getting poor results, but it is rising steadily.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  18. #18
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope, no polls on my sites right now - focusing more on content and such. The only recommendations I can give to try to increase poll participation is to make it clearly visible, and perhaps keep it somewhere on every page of your site.

    In addition, going out of you way to ask interesting questions will help, as well taking away a "View Results" option - people will vote just to see where the vote total stands - I do that all the time.

  19. #19
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm...COOL!
    hmm...thats a good idea..okie..
    point noted! ehehz =)

    Thanks TWTCommish.
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein


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
  •