Current location: Hot Scripts Forums » Programming Languages » PHP » Deleting Files from Server


Deleting Files from Server

Reply
  #1 (permalink)  
Old 02-05-07, 12:43 AM
sccc2008 sccc2008 is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Deleting Files from Server

Hello,

im having an issue deleting a file from the server. The situation is that I have a file on the server, and the file name is on a database.

Currently I am using the following script to remove the file, but this isnt working. I think that it might have something to do with the CHMOD 777 command. If anyone knows what im doing wrong, please advise.

PHP Code:

require_once(databaseconnection.php');

$query="SELECT filename FROM photo WHERE VALUE1=VALUE2";
mysql_query($query) or die('
Errorquery failed');
$result = @mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_BOTH); 


if($row[0]!==NULL)
{
chmod( $row[0], 0777 );
unlink( $row[0] );

header("Location: newpage.htm");



Last edited by Nico; 02-05-07 at 04:43 AM. Reason: Please use [php] wrappers when posting PHP code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-05-07, 04: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
you have an error in your syntax: you forgot to open a quote on the first line:
PHP Code:

require_once('databaseconnection.php'); 

ig you fix this, it might work

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-05-07, 08:11 PM
sccc2008 sccc2008 is offline
Newbie Coder
 
Join Date: Jan 2007
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
oh im just using that as an example, in the real query, it is not like that, but i appreciate the input.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-05-07, 09:04 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Posting code that is changed from the actual code to the point of introducing additional errors, just causes wasted effort and wild goose chases.

If you modify your code for posting, at east have the decency of proof-reading it to insure that it accurately represents the problem that you need help with.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-05-07, 11:32 PM
daveganley daveganley is offline
Newbie Coder
 
Join Date: Jun 2003
Location: London UK
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Does $row[0] contain just the name of the pic?
If so is the pic located in the same directory as the script?
If not it's a file path problem.

Please post your full code and dir structure, if you still need help

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
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
Browser wants to download -- not display -- HTML files from my server mangled Web Servers 5 01-20-07 02:39 PM
Deleting Files from Server sccc2008 PHP 1 01-19-07 12:57 AM
List files from another server kailexx PHP 1 08-27-05 02:37 PM
How to copy files from remote server to local server without using ftp connection... ajay007_bond PHP 5 06-15-05 11:35 PM
move files around an ftp server, with php file upload script? wapchimp PHP 2 12-19-04 08:27 AM


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