How To Delete

Started on the old forum in November 2007 · view the original in the archive · old links redirect here

7 replies · 562 views · started 19 years ago · 1 min read

3 participants
Guest #1

**i make alone in script to can delete but dont work, anybody can help my to fix this problem ?**CODE<?php include("../config.php"); include("../core.php"); connectdb(); $site = $_GET["site"];

$sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'")); $sitename = $sitename[0]; $uip = getip(); $action = $_GET["action"]; $sid = $_GET["sid"]; $page = $_GET["page"]; $who = $_GET["who"]; $uid = getuid_sid($sid); $theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));

 header("Cache-Control: no-cache, must-revalidate");	        // Prevent caching, HTTP/1.1

header("Pragma: no-cache"); echo '<?xml version="1.0"?' . '>'; echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";

echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";

if($action=="main") { addvisitor(); addonline(getuid_sid($sid),"upload music","index.php?action=$action");

    echo "<head>";
echo "<title>$sitename Upload</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";

echo " ";

echo "Best music ";

$limit          = 10;               
$query_count    = "SELECT id, COUNT(*) FROM ibwf_music GROUP BY id";    
$result_count   = mysql_query($query_count);    
$totalrows      = mysql_num_rows($result_count); 

    if(empty($page)){
    $page = 1;
}
    

$limitvalue = $page * $limit - ($limit); 
$query  = "SELECT * FROM ibwf_music ORDER BY id DESC LIMIT $limitvalue, $limit";        
$result = mysql_query($query) or die("Error: " . mysql_error()); 

if(mysql_num_rows($result) == 0){
    echo("nici un fisier!

"); }

$bgcolor = "#E0E0E0"; // light gray


while($row = mysql_fetch_array($result)){
    if ($bgcolor == "#EFE0E0"){
        $bgcolor = "#FFFF0F";
    }else{
        $bgcolor = "#E0E0E0";
    }

$usr = getnick_uid($row[uid]);

if(isonline($row[uid]))

{

$iml = "<img src=\"../images/onl.gif\" alt=\"+\"/>";

}else{

$iml = "<img src=\"../images/ofl.gif\" alt=\"-\"/>";

} if(isowner(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0]) { $lnk = "<a href="index.php?action=delete&who=$item[0]&sid=$sid">[x]</a>"; } echo "<a href="./files/$row[filename]">$row[filename]</a> ($row[filesize]) BY: <a href="../index.php?action=viewuser&who=$row[uid]&sid=$sid">$iml $usr $lnk</a> "; } echo " "; echo " "; if($page != 1){ $pageprev = $page-1; echo("<a href="index.php?action=$action&page=$pageprev&sid=$sid">prev</a> "); }

echo "**|**";
 if(($totalrows - ($limit * $page)) > 0){
    $pagenext = $page+1;
     
    echo("<a href=\"index.php?action=$action&amp;page=$pagenext&amp;sid=$sid\">next</a>"); 
}

echo " ";

$numofpages = $totalrows / $limit; 

for($i = 1; $i <= $numofpages; $i++){
    if($i == $page){
        echo($i." ");
    }else{
        echo("<a href=\"index.php?action=$action&amp;page=$i&amp;sid=$sid\">$i</a> ");
    }
}

if(($totalrows % $limit) != 0){
    if($i == $page){
        echo($i." ");
    }else{
    	
        echo("<a href=\"index.php?action=$action&amp;page=$i&amp;sid=$sid\">$i</a> ");
    }
}




mysql_free_result($result); 

///echo " Fisiere totale: $countfile "; echo " Page $page from $numofpages ";

echo "<img src=\"../images/line.gif\" alt=\"\"/>

"; echo "<a href="../extra.php?action=main&sid=$sid">extra</a>"; echo "||"; echo "<a href="../index.php?action=main&sid=$sid">home</a>"; echo " "; echo "</body>"; echo "</html>"; }else{ echo popup($sid); } if($action=="delete")

{

$uid = $_GET["uid"];

  echo "<head>";

  echo "<title>$sitename</title>";

  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/$theme[0]\">";

  echo "</head>";

  echo "<body>";

echo " ";

$itemowner = mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_music WHERE id='".$uid."'"));

if(isowner(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0])

{

$res = mysql_query("DELETE FROM ibwf_music WHERE id='".$uid."'");

if($res)

    {

        echo "<img src=\"images/ok.gif\" alt=\"o\"/>file deleted

";

    }else{

      echo "<img src=\"images/notok.gif\" alt=\"x\"/>Eror!

";

    }

}else{

echo "<img src=\"images/notok.gif\" alt=\"X\"/>Cant delete";

}

echo " "; echo "<img src="../images/line.gif" alt=""/> ";

echo "<a href="../index.php?action=main&sid=$sid">home</a>";

echo "

</body>";

}

?>

blackhowk Senior · 411 posts #3

$res ="DELETE * FROM ibwf_music WHERE id='$uid'; mysql_query($res);

or

$res ="DELETE FROM ibwf_music WHERE id='$uid'; mysql_query($res);

i dnno if work, check the variable status $uid

ori Lead · 512 posts #4

u can use the function unlink($path.$filename);

Guest #5

how ori?

ori Lead · 512 posts #7

normally works from same folder link in the () but url as well may work not sure

if($action=="delete"){ unlink("./".$file.$ext); }

Guest #8

mai explica odata, vrei sa stergi in baza de date sau in folder?

frate vreau mai mult sa sterg din baza de date sa nu apara in pagina ca fisierele mi le sterg eu cu ftp

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close