Ok, so I tried to delete files from the DB and from the dir they are stored on, and i encountered a problem, the mysql_fetch_array wouldn't fetch an array to the SQL.
here is the code:
<?php
if (isset($_POST['delete']))
{
$file_dir = "user-files/";
$to_del = implode(",",$_POST['del']);
$delete = mysql_query("DELETE FROM `files` WHERE `id` IN (".$to_del.")") or die (mysql_error());
$to_del_link = explode(",",$to_del);
foreach ($to_del_link as $key => $id)
{
$sql = "SELECT `filename` FROM `files` WHERE `id` = '".$id."'";
echo $sql."<br />";
$_qr = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_array($_qr);
unlink($file_dir.$row['filename']);
if (!is_file($file_dir.$row['filename']))
{
echo "The file '".$row['filename']."' was successfully delted!<br />";
}
else
{
echo "A problem occured in the file(s) deleting!<br />";
}
}
}
?>
it prints the right SQL query in here:
echo $sql."<br />";
but it doesnt fetchs an array to it, I don't get the filename to delete.
somebody knows what's the problem?