NameSilo

Unlink - Need help

Spaceship 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
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back