I have a problem with the code below,
Code: Select all
if ($event == "stopped") {
if (isset($self)) {
$res = mysql_query("SELECT leeched_for, torrent, userid, UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(MIN(started)) AS seeded_for, username, recent_change, seed_time FROM peers, users WHERE seeder = 'yes' AND peers.userid='$userid' AND users.id='$userid' GROUP BY userid") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0) {
while ($arr = mysql_fetch_assoc($res)) {
if ($arr["torrent"] == $torrentid) {
$seeding_for = $arr["seeded_for"] - $arr["leeched_for"];
$dummy = $seeding_for - $arr["recent_change"];
mysql_query("UPDATE users SET seed_time = seed_time + $dummy, recent_change = $seeding_for WHERE id = $CURUSER[id]") or sqlerr(__FILE__, __LINE__);
}
}
}
mysql_query("DELETE FROM peers WHERE $selfwhere");
}
}When i put the DELETE query just under the SELECT query, the DELETE query is always done, but the update is never executed.
Well, it is something like a sequence, if the above is done, the one below it isn't executed. So I want always the delete query to be done, and if the select query is true, the update query is executed then the delete query is executed.