Current location: Hot Scripts Forums » Programming Languages » PHP » delete problems


delete problems

Reply
  #1 (permalink)  
Old 09-28-06, 04:21 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
delete problems

Hi there...

the 3 attached files are a script to delete a certain folder.
You choose the folder you want to delete in the deleting.php file.
(the choices look like: "001) name_of_the_folder")

After you choose the folder (named: "name_of_the_folder")
the directory "name_of_the_folder" should be delete.
as well as the row with "name_of_the_folder" in galleries.txt file.
This is done in delete.php

As far as I can tell all needed things are there in the two files.
But somehow it isn't working

who can help....
Attached Files
File Type: txt delete_php.txt (1.0 KB, 65 views)
File Type: txt deleting_php.txt (1.2 KB, 69 views)
File Type: txt galleries.txt (215 Bytes, 49 views)
Reply With Quote
  #2 (permalink)  
Old 09-28-06, 04:32 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
in delete.php: try placing "continue" in the body of the if in the while loop:
PHP Code:

    while($line2) {

        if(
$count == $item) {
           continue;
        }
        else {
            
fputs($file2$line2);
        }
        
$line2 next($temp2);
        
$count++;
    } 
what isn't working exactly? is the directory being removed, or not? or is the file not updated?

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 09-28-06, 04:51 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
this item is removed from the txt file correctly..

but all folders inside "gallerie" are removed. not just the selected one.

check it on:

www.freelaxed.com/meno/gallerie/verwijderen.php

to see what happens

(excuse me for this site to be in Dutch...)
Reply With Quote
  #4 (permalink)  
Old 09-28-06, 04:56 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
you're getting the error: cannot remove dir. make sure that your file/folder permission are set so you everyone can delete files or folders.
let's say you have to make sure te folderpermissions of the fotoalbum folder must be set to 0777 so the galleries can be removed.

Quote:
Originally Posted by jonnekke
(excuse me for this site to be in Dutch...)
no worries, i'm from belgium

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #5 (permalink)  
Old 09-28-06, 05:06 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
the file/folder permission is 0777... and the folders are deleted.. that's the wierd part of it... I think (as far as i can see) that $dir is empty..

I got no clue how get $dir = name_of_the_folder...
Reply With Quote
  #6 (permalink)  
Old 09-28-06, 05:32 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
i think i got the problem. it's just as you said. the $dir var is emty, that way it will try to delete the galleries folder. which it's not allowed to do i guess?

the following error than takes place:
Code:
Warning: rmdir(fotoalbum/galleries/): Permission denied in /home/httpd/vhosts/freelaxed.com/httpdocs/meno/gallerie/verwijder.php on line 82
do you have register_globals on? if so, you'ld better turn them off, and use $_POST or $_GET to access those variables.

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #7 (permalink)  
Old 09-28-06, 05:37 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
have you got a clue how to get the data I need
from the txt file?..

in deleting.php (in the drop down) it's
shown as "001) folder"

it's written in php as:

$line2 = "$count2.) $data[$teller]

that's what is think...

but $data[$teller] is not "folder"

how can I extract "folder" and make
$dir = folder ...(in this example)
Reply With Quote
  #8 (permalink)  
Old 09-28-06, 05:42 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
you can use explode or split to split the string:
PHP Code:

list($line$dir) = split(')'$item2);

// or:
$explode explode(')'$item);
$line $explode[0];
$dir $explode[1]; 
what do you mean by reading the file? you're using the file function which is correct. file_get_contents will work as well

Hope this helps a little,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #9 (permalink)  
Old 09-28-06, 05:51 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
and where should I place it in the deleting.php..
or should it be placed in delete.php?..
Reply With Quote
  #10 (permalink)  
Old 09-28-06, 05:54 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
this should be placed in delete.php at the beginning of your code.
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
secure delete adubb PHP 3 05-14-06 10:30 PM
problems uploading_can pay something babalu Job Offers & Assistance 0 10-23-05 10:47 AM
Delete files/directories selected in MySQL ronlar PHP 3 08-08-05 08:41 AM
Delete row from mysql error. bigkid PHP 1 08-05-04 09:36 PM
i know how to delete a file! but how to delete a directory? forcer JavaScript 3 01-28-04 07:00 AM


All times are GMT -5. The time now is 05:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.