I made this code... And offcoarse its not working 🙁
Anyway, when i run it it shows me a permission denied error on the directory...
Theres is no filename shown... When i manually put in the file name (hardcode it) it works... But it should query the database for the name $getsmile3[picture] holds the filename! But its not aquired... Any ideas how?
gets frustrated here
if(isset($_POST['submit'])) {
$smileID=$_POST['smileID'];
$getsmile="SELECT * FROM smileys WHERE smileid='$smileID'";
$getsmile2=mysql_query($getsmile) or die("Could not get smileys");
$getsmile3=mysql_fetch_array($getsmile2);
$getvars="SELECT serverpath from bl_vars";
$getvars2=mysql_query($getvars) or die("Could not get variables");
$getvars3=mysql_fetch_array($getvars2);
$dir = "$getvars3[serverpath]/images/smileys";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
unlink("$dir/$getsmile3[picture]");
closedir($dh);
}
}
$delsmiley="DELETE FROM smileys WHERE smileid='$smileID'";
mysql_query($delsmiley) or die("Could not delete smiley!");
// print "<META HTTP-EQUIV = 'Refresh' Content = '1; URL =smileys.php'>";
print "Smiley deleted";
} else {
$smileID=$_POST['smileID'];
print "Are you sure you want to delete this smiley?";
print "<form action='deletesmiley.php?smileID=$smileID' method='post'>";
print "<input type='submit' name='submit' value='delete smiley'></form>";
}
Also when i have hardcoded the filename init, and it works... it still does not delete the db row... like it should in thise part:
$delsmiley="DELETE FROM smileys WHERE smileid='$smileID'";
mysql_query($delsmiley) or die("Could not delete smiley!");