Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-21-2011, 11:32 AM   PM User | #1
phpfrnd
New Coder

 
Join Date: Jan 2011
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
phpfrnd is an unknown quantity at this point
Unlink function not working

Hello
This is my code ,
i want to delete databse row and image from folder
it delete only database row,but it not delete image from folder...Why?
Please Help me

<?php
include('config.php');
$id=$_REQUEST['id'];
$image=$_REQUEST['image'];
$target_path='upload/';
if(isset($_REQUEST['action'])=='delete')
{
$query="delete from tbl_user where id='$id'";
$r1=mysql_query($query) or die(mysql_error());
unlink($target_path.$image);
header('Location:welcome.php');

}

?>


Thank you
phpfrnd is offline   Reply With Quote
Old 04-21-2011, 11:42 AM   PM User | #2
tomharto
Regular Coder

 
Join Date: Jul 2010
Location: Sheffield
Posts: 807
Thanks: 92
Thanked 18 Times in 18 Posts
tomharto is on a distinguished road
What id suggest trying first is looking at the string its trying to unlink

PHP Code:
<?php
include('config.php');
$id=$_REQUEST['id'];
$image=$_REQUEST['image'];
$target_path='upload/';
if(isset(
$_REQUEST['action'])=='delete')
{
$query="delete from tbl_user where id='$id'";
$r1=mysql_query($query) or die(mysql_error());
 echo 
"".$target_path.$image."";
}

?>
and checking the path and file are correct.
tomharto is offline   Reply With Quote
Old 04-21-2011, 06:04 PM   PM User | #3
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You can also check the return value from unlink() to see if it's true or false. You should probably comment out your header() call while you're trying to get this working because there may be an error message you're missing due to the immediate redirect.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:59 PM.


Advertisement
Log in to turn off these ads.