function increment_skip($connection, $username) { $sql_query = "UPDATE googlockusers SET skipped=skipped+1 WHERE username='******'"; //lock put_lock($connection, "googlockusers", "write"); $temp = mysql_query($sql_query, $connection); remove_lock($connection); //unlock }
$sql_query = "select username,score from googlockusers ORDER BY score desc limit 0, 1"; //lock put_lock($connection, "googlockquestions", "read"); $temp = mysql_query($sql_query, $connection); remove_lock($connection); //unlock $no_of_records = mysql_num_rows($temp); for ($i = 0; $i < $no_of_records; $i++) { //setcookie( either the cookie method in which a javascript is used to keep tab //else we can use a hidden form an check if the values are not null. if null this is the first time this form has been //visited, keep a counter and after every 5 refreshes or so give fresh values.also note that after refresh the values are deleted therefore the php script has to check and set the values every time( no need to set fresh values, just the stale ones back again) } $result3 = mysql_fetch_array($temp); $sql_query = "select score from googlockusers where username='******'"; //lock put_lock($connection, "googlockusers", "read"); $temp = mysql_query($sql_query, $connection); remove_lock($connection); //unlock $result2 = mysql_fetch_array($temp); mysql_close($connection); if (isset($_COOKIE["time"]) == FALSE || stristr($_COOKIE["time"], "undefined") || stristr($_COOKIE["time"], "NaN")) { $raw_time = $duration - $diff; $hours = floor($raw_time / 3600); $raw_time = $raw_time % 3600; $minutes = floor($raw_time / 60); $seconds = $raw_time % 60; $to_send = $hours . ":" . $minutes . ":" . $seconds . ":"; setcookie("time", $to_send, 0, '/'); } } else {