When deleting a torrent from registered users,
the script doesn't update the database on 'uploads' and 'comments'
table for each user. If a user have 10 torrents uploaded, when I run
the script, the 'uploads' table is updated to 0 and 'comments' stay
the same.
Anybody knows how to do this works fine? Here the code
that I'm using.
here you find my script =
http://teste.dannlopes.cjb.net/
Quote:
$result = mysql_query("SELECT * FROM
torrents LEFT JOIN users ON torrents.posted_by = users.username
WHERE id = '$id' LIMIT 1") or die (mysql_error());
if
(!$posted_by == 0){ // if user is registered, because guest users
are set to 0
while ($row =
mysql_fetch_array($result)){
extract($row);
mysql_query("UPDATE
categories SET torrents = 'torrents-1' WHERE subid = '$subcat' LIMIT
1") or die (mysql_error());
mysql_query("DELETE FROM comments
WHERE id = '$id' LIMIT 1") or die
(mysql_error());
mysql_query("DELETE FROM description WHERE id =
'$id' LIMIT 1") or die (mysql_error());
mysql_query("DELETE FROM
torrents WHERE id = '$id' LIMIT 1") or die (mysql_error());
//the
line below I'm trying to use but didn't work, a try to use this line
after 'while' but didn't work again
mysql_query("UPDATE users SET
uploads = 'uploads-1' WHERE username = '$posted_by' LIMIT 1") or die
(mysql_error());
@unlink('.'.$btdir.'/'.$hash.'.bogtor');
}
}
else{
// if guest user
while ($row =
mysql_fetch_array($result)){
extract($row);
mysql_query("UPDATE
categories SET torrents = 'torrents-1' WHERE subid = '$subcat' LIMIT
1") or die (mysql_error());
mysql_query("DELETE FROM comments
WHERE id = '$id' LIMIT 1") or die
(mysql_error());
mysql_query("DELETE FROM description WHERE id =
'$id' LIMIT 1") or die (mysql_error());
mysql_query("DELETE FROM
torrents WHERE id = '$id' LIMIT 1") or die
(mysql_error());
@unlink('.'.$btdir.'/'.$hash.'.bogtor');
}
}