Be a Supporter!

Php Unlink Problems

  • 483 Views
  • 7 Replies
New Topic Respond to this Topic
Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Php Unlink Problems 2006-11-13 15:16:42 Reply

Hey, i'll get straight to the point.

I made a script to delete everything (the SWF file, the avatar file, the entry in the DB) from a flashportal I am making. Here is the code:

<?php
$query = mysql_query("SELECT * FROM `portal` WHERE `rating` <= '0.25' AND `rating` > '0' AND `num_votes` > '5'") or die( mysql_error() );
$count = mysql_num_rows($query);

if($count != "0"){

while($r=mysql_fetch_array($query)){ // For every thing in the voting that has a score lowed than 0.25 delete it.

$id = stripslashes($r['id']);
$avatar = stripslashes($r['avatar']);
$swffile = stripslashes($r['file']);
unlink("swfs/".$swffile."");//Delete swf file
if($avatar == "movieavat.png"){
// Do nothing
} elseif($avatar == "gameavat.png"){
// Do nothing
} else {
unlink("avatars/".$avatar."");//Delete avatar
}

mysql_query("DELETE * FROM `portal` WHERE `id` = '$id' LIMIT 1"); // Delete from table

}//End while loop

}
?>

I get this error though:

Warning: unlink(swfs/1379hitler_Scene 1.swf) [function.unlink]: No such file or directory in /home/landoff/public_html/flash-portal/blam.p hp on line 12

I looked in FTP, and the file (1379hitler_Scene 1.swf) was not there. Why is it displaying this message if it deleted the file correctly?

elbekko
elbekko
  • Member since: Jul. 23, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:18:03 Reply

Maybe you're operation from the wrong folder? Or tried to delete the same file twice in the loop?


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature
Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:18:44 Reply

Sorry, what it should say before the script is this:

Hey, i'll get straight to the point.

I made a script to delete everything (the SWF file, the avatar file, the entry in the DB) from a flashportal, where the score is less than 0.25, when it has got more than 5 votes, but when its rating is not 0. I am making. Here is the code:

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:28:42 Reply

I'm operating from here:
http://www.landofflash.com/flash-portal/

And the swf folder is here:
http://www.landofflash.com/flash-portal/swfs/

elbekko
elbekko
  • Member since: Jul. 23, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:30:04 Reply

Then the file musy've occured multiple times in the loop.


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature
Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:39:02 Reply

But it cannot have. You can see that right there in the code.

elbekko
elbekko
  • Member since: Jul. 23, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:41:14 Reply

Do you have a better explanation? :P It's the only thing I can think of really =/


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature
Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Php Unlink Problems 2006-11-13 15:50:03 Reply

Fixed sorry. Don't worry.

:D