Author Topic: problem is always "Sorry, you've already rated for this image once recently"  (Read 4989 times)

0 Members and 1 Guest are viewing this topic.

Offline ilaslan

  • Newbie
  • *
  • Posts: 44
    • View Profile
hello

in page_header.php there is
 if (!in_array($id$split_list) && !in_array($id$cookie_rated)) {
      
$session_info['rated_imgs'] .= " ".$id;
      
$session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      
$site_sess->set_session_var("rated_imgs"$session_info['rated_imgs']);
      
$cookie_rated[] = $id;
      
$cookie_expire time() + 60 60 24 4;
      
setcookie($cookie_name.'rated'serialize($cookie_rated), $cookie_expireCOOKIE_PATHCOOKIE_DOMAINCOOKIE_SECURE);
      
update_image_rating($id$rating);
      
$msg $lang['voting_success'];
    }
    else {
      
$msg $lang['already_voted'];
    }
  }
  else {
    
$msg $lang['voting_error'];
  }


and i didn't change anything in this code.
but. i have a problem. if i rated  a pic first.. There is " Sorry, you've already rated for this image once recently "  in message but. rating is updating.

if i rate again " Sorry, you've already rated for this image once recently "  in message and rating is not updated.

How? Where is the problem?

Offline tutton

  • Newbie
  • *
  • Posts: 13
    • View Profile
I don't think you can rate an image more than once
So it will not change if you try to rate it again

Offline ilaslan

  • Newbie
  • *
  • Posts: 44
    • View Profile
if i rate again no prolem msg is true : " Sorry, you've already rated for this image once recently   "

problem is first rate. if i rate first. update vote is ok but message is :" Sorry, you've already rated for this image once recently   "

 i had changed in function.php  function update_image_rating($image_id$rating){  ....   }

but message musn't change. i think?
Do you have an idea?

i don't understand in first post , if ihave first rate

 if (!in_array($id$split_list) && !in_array($id$cookie_rated)) { ...

update_image_rating($id$rating);  <-- this code is working
...
else { 
$msg $lang['already_voted'];      <-- this code is working  }

}  


maybe one click and two rate , two details.php  but how?
 

« Last Edit: January 23, 2011, 02:28:14 PM by ilaslan »

Offline ilaslan

  • Newbie
  • *
  • Posts: 44
    • View Profile
Hello Vano and Other Experts

i am still on this problem

and i think problem is.
in function php.

i had wanted to this.

http://www.4homepages.de/forum/index.php?topic=28005.msg151513#msg151513
and i try. and i did.

my php and sql knowledge is very little
so i write this. for top.html and main.html maybe other templates...

function update_image_rating($image_id$rating) {
 


 
$query "SELECT COUNT(*) AS count FROM ".IMAGES_TABLE."
WHERE alioldu > (SELECT alioldu FROM "
.IMAGES_TABLE." WHERE image_id='$image_id')
ORDER BY alioldu DESC" 
;

$q mysql_query($query) or die(mysql_error());
$a mysql_fetch_array($q,MYSQL_ASSOC);
$kac $a['count'];
 
 
$query "SELECT COUNT(*) AS count FROM ".IMAGES_TABLE."
WHERE aliresim > (SELECT aliresim FROM "
.IMAGES_TABLE." WHERE image_id='$image_id')
ORDER BY aliresim DESC"
;

$q mysql_query($query) or die(mysql_error());
$a mysql_fetch_array($q,MYSQL_ASSOC);
$kac2 $a['count'];

$kacisin $kac $kac2;



 global 
$site_db;
  
$sql "SELECT cat_id, image_votes, image_rating, image_hits, alioldu, aliresim, olacak, yuzdepuan
          FROM "
.IMAGES_TABLE."
          WHERE image_id = 
$image_id";
  
$image_row $site_db->query_firstrow($sql);
  if (
check_permission("auth_vote"$image_row['cat_id'])) {
    
$old_votes $image_row['image_votes'];
    
$old_rating $image_row['image_rating'];
	
$old_image_hits $image_row['image_hits'];
    
$new_rating = (($old_rating $old_votes) + $rating) / ($old_votes 1);
    
$yeni_alioldu = (($new_rating) * ($old_votes 1))*10 / ($old_image_hits);
	
$yeni_aliresim = (($new_rating) * ($old_votes 1));
	

.....

	
$sql "UPDATE ".IMAGES_TABLE."
            SET image_votes = (
$old_votes + 1), image_rating = '$new_rating', alioldu = '$yeni_alioldu', aliresim = '$yeni_aliresim', olacak = '$kacisin', yuzdepuan = '$yeni_yuzdepuan'
            WHERE image_id = 
$image_id";
    
$site_db->query($sql);
  }
}

and this code is working, same is in details php.

maybe many sql query is a problem i think. but only one $sql = "UPDATE ".IMAGES_TABLE."

and i haven!t solve this. double votes. and always this message " Sorry, you've already rated for this image once recently   "