Page 1 of 1

very very strange problem with unlink

Posted: Tue Dec 14, 2004 9:26 am
by pelegk2
i have this code :

Code: Select all

for($i=0;$i<count($delLst); )
      unlink($delLst&#1111;$i++]);
always when the loop is at its last index
it can't delete the file that is in that index,not metter what the file!!!
i tried iffrent cobmination and every time the same problem!
always the last file isnt deleted and i get a permission denied warning!
why is that?
thnaks in advance
peleg

Posted: Tue Dec 14, 2004 9:55 am
by timvw
it is because apache or whoever executes the php code is not allowed to delete the files.



use php tags instead of code ;)

imho cleaner ways to write that loop are:

Code: Select all

foreach($delLst as $file)
{
  unlink($file);
}

Code: Select all

for ($i = 0; $i < count($delLst); ++$i)
{
  unlink($delLst[$i];
}

well

Posted: Tue Dec 14, 2004 11:39 am
by pelegk2
you wrote :
it is because apache or whoever executes the php code is not allowed to delete the files
well its not thep roblem!!!!
beacuse f for example the last file iss 3333.txt
and it dosent delete it
i add a new file called 44444.xt
and now 4444.txt isnt being deleted!!!!!

if it matters i am working with apache 2.0.46 and php 4.3.2 on win 2000

Posted: Tue Dec 14, 2004 2:09 pm
by rehfeld
post the actual error code

Posted: Wed Dec 15, 2004 12:37 am
by pelegk2
ok found it
ihave left a fopen() iwth a pointer to the file beacuse of that1