Jump to content

[SOLVED] unlink not working


dennismonsewicz

Recommended Posts

Code:

 

$query2 = mysql_query("SELECT * FROM uploads where id = " . $id . "");

							$row = mysql_fetch_array($query2);

							$filename = $row['name'];

							$imgdir = "imageuploads/";

							unlink($imgdir . $filename);

 

For some reason the above code does not work. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/100695-solved-unlink-not-working/
Share on other sites

For starters, add error checking on the query:

 

<?php
$sql = "SELECT * FROM uploads where id = $id";
$result = mysql_query() or die(mysql_error().'<br />On the query:'.$sql);
if(mysql_num_rows($result) == 1){
    $row = mysql_fetch_assoc($result);
    $filename = $row['name'];
    $imgdir = "imageuploads/";
    unlink($imgdir . $filename);
}else{
    echo 'ID does not exist!';
}

?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.