Filesoup
X   Site Message
(Message will auto close in 2 seconds)


> 

If you would like to advertise your Hosting, Services or Products on Filesoup, please contact Geeker for a quote.

 
Reply to this topicStart new topic
> Problem in admin/delete.php, T-xore modified
guibean
post May 20 2007, 11:55 PM
Post #1


Spam Soup
Group Icon

Group: Contributor
Posts: 117
Joined: 22-September 05
Member No.: 313,949
 


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/


CODE
         $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');
       }
       }


--------------------
Go to the top of the pageReport Post
+
guibean
post May 21 2007, 11:30 PM
Post #2


Spam Soup
Group Icon

Group: Contributor
Posts: 117
Joined: 22-September 05
Member No.: 313,949
 


Complete Code in admin/delete.php

CODE
<?

require_once '../config.php';
require_once '../admin/secure.php';
connect ($dbhost, $dbuser, $dbpass, $database);

$id = $_GET['id'];
$result = mysql_query("SELECT * FROM torrents WHERE id = '$id' LIMIT 1");
if (mysql_num_rows($result) == 0){
    die ('Torrent n&atilde;o encontrado');
}

$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){
    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());
        mysql_query("UPDATE users SET uploads = 'uploads-1' WHERE username = '$posted_by' LIMIT 1") or die (mysql_error());
        @unlink('.'.$btdir.'/'.$hash.'.bogtor');
    }
}
else{
    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');
    }
}
?>



Help ME
Go to the top of the pageReport Post
+

Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
1 Members: OPPZeroCool

 




Homeowner Loan | Bad Credit Loan | Discount Magazine | Xanga Script Forums | Cadillac CTS
-
Lo-Fi Version 0.1177 sec    --    12 queries    GZIP Enabled
Time is now: 23rd May 2007 - 01:49 PM