Dynadot โ€” .com Transfer

Unlink - Need help

SpaceshipSpaceship
Watch

bluemouse2

Established Member
Impact
10
Hi!
Can you please help me delete several files with unlink?
php Code:

PHP:
 $sql = "select filename from $aaa where owner='$id'";
   $result = mysql_query($sql) or die("Failed: $sql");
   $resrow = mysql_fetch_row($result);
 $filename = $resrow[0];
 @unlink("./files/".$filename);


this code deletes only one file.
there are several files to delete.

where do i go wrong? thanks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
 $sql = "select filename from $aaa where owner='$id'";
   $result = mysql_query($sql) or die("Failed: $sql");
  while ($row = mysql_fetch_array($result)) {
        @unlink("./files/".$row[0]);
}

Try this
 
Last edited:
1
•••
Thank you!
 
0
•••
no prob.
You can / should use mysql_fetch_row like you did in your code since your going to return an enumerated array
 
0
•••
The @ opertor is extremely slow. It'd be best if you checked if the result file existed, and then unlinked it.
 
0
•••
its not extermely slow ... it's slower.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back