SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    NJ
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gallery rating system, user validation

    I've picked up an image gallery script from SourceForge that is almost perfect for what I want with one exception. The rating system sporadically allows multiple votes from the same user and I'm not sure why. This is the code used to determine if an image has already been rated;
    PHP Code:
    <?php
    function already_rated($nom)
    {
      global 
    $sDB,$nConnection,$sTableRatings;
      
    $cmd="select * from $sTableRatings where pic_name='".addslashes($nom)."' and ip='".getenv("REMOTE_ADDR")."'";
      
    $res=mysql_db_query($sDB,$cmd,$nConnection);
      
    $row=mysql_fetch_array($res);
      return(
    $row);
    }
    ?>
    This is the code associated with retrieving the rating;
    PHP Code:
    <?phpfunction get_rating($nom)
    {
      global 
    $sDB,$nConnection,$sTableRatings;
      
    $cmd="select avg(rating), count(*) from $sTableRatings where pic_name='".addslashes($nom)."'";
      
    $res=mysql_db_query($sDB,$cmd,$nConnection);
      
    $row=mysql_fetch_array($res);
      return (
    $row[1]?$row[0]:false);
    }
    ?>
    Now in the MySQL the table for ratings has the IP number along with the image file name. What I can't figure out is why when it checks to see if the image has already been rated it does not return the IP in that table and deny another vote.

    This may not be enough information and if not I would be happy to offer more, along with the URL where this is set up. Any suggestions on where to start looking to resolve this issue would be greatly appreciated.

    Cheers!
    Hosting with integrity, tvihosting.com

    Custom Web designs,Templates and related graphic work,
    are also available.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of PHP are you testing with ?

    Also you might as well post more script if you've got it ?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    NJ
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply!

    It would seem that the issue was with caching and that was causing sporadic issues for re-voting. I added the header lines to flush the cache and it works perfectly....thanks!
    Hosting with integrity, tvihosting.com

    Custom Web designs,Templates and related graphic work,
    are also available.


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
  •