NameSilo

Unlink - Need help

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
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
•••
Olitt — high-converting AI websites, only from $1/moOlitt — high-converting AI websites, only from $1/mo

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back