Re: Need help for $unlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Avi,
 
Looking your code I knew that you are onli deleting Records from your Table.
At 1st you have to delete your stored file from folder named "uploads". To do this you have to get the filename (path) from the records, like this way:
 
Getting filename from ID:
------------------------------------------
<?php
$ImgID = $_REQUEST['m_ id'];
$SQL= "Select FROM model_photos WHERE m_id='$ImgID ' ";
$imgResult= mysql_query( $SQL) or die('Query failed: ' . mysql_error( ));
$TotalRec=mysql_num_rows($imgResult);
if($TotalRec>=1){
$row = mysql_fetch_array($imgResult);
$imgFile=$row['Col Name']; //Where your file name stored
unlink($imgFile);
 
//when you getting error code while unlink file like permission denied then you have change the permision of that file before deleting it
//Just put chmod() function just before unlink() function. Like: chmod($imgFile,0755) access primision to everyone
 
 
//Now you can delete your database also
 

$m_id = $_REQUEST['m_ id'];
$query = "DELETE FROM model_photos WHERE m_id='$m_id' ";
$result = mysql_query( $query) or die('Query failed: ' . mysql_error( ));
}
?>

Regards & Thank You,


Suman K. Rai
Cell: +977 98040 25616
rai.suman@xxxxxxxxx | sumanrai1980@xxxxxxxxx
www.raisuman.myplace.com


--- On Fri, 1/2/09, arvindsri123 <arvindsri123@xxxxxxxxx> wrote:


From: arvindsri123 <arvindsri123@xxxxxxxxx>
Subject:  Need help for $unlink
To: php-objects@xxxxxxxxxxxxxxx
Date: Friday, January 2, 2009, 9:31 PM






Hello All,

I am storing/inserting 10 images in a database and files stored
in"uploads" folder.

Now I am using below code to delete all , here is code. but its only
deleting from database, all the images are still existing in "uploads"
folder. I want to delete them(images) too when i run below script.

<?php 
$m_id = $_REQUEST['m_ id'];
$query = "DELETE FROM model_photos WHERE m_id='$m_id' ";
$result = mysql_query( $query) or die('Query failed: ' . mysql_error( ));

?>

waiting for positive response.... will be thank full to you.

Thanks,
Avi

 














      

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux