regoch Posted March 7, 2010 Share Posted March 7, 2010 <?php // connect to the database include('connect.php'); // check if the 'id' variable is set in URL, and check that it is valid if (isset($_GET['id_slike']) && is_numeric($_GET['id_slike'])) { $id_slike=$_GET['id_slike']; $rezultat=mysql_query("SELECT * FROM slike WHERE id_slike=$id_slike ORDER BY id_slike ASC LIMIT 1"); $redak=mysql_fetch_array($rezultat); $myFile=$redak['picture_name']; $fh=fopen($myFile, 'w') or die("can't open file"); fclose($fh); unlink("../slike/".$myFile); unlink("../slike/thumbnails/".$myFile); // delete the entry $result = mysql_query("DELETE FROM slike WHERE id_slike=$id_slike") or die(mysql_error()); // redirect back to the view page header("Location: index.php"); } else // if id isn't set, or isn't valid, redirect back to view page { header("Location: index.php"); } ?> Hail! I found this script on net, add delete form database it and it's work fine. Delete picture, delete thumbnail, and row in database. Script is called brisanje.php. But script creates jpg file called same name as deleted picture but with 0 mb size. Why this does that? Not much problem, more like wonna know why! Quote Link to comment https://forums.phpfreaks.com/topic/194429-unlink-let-callit-some-kind-of-trouble/ Share on other sites More sharing options...
premiso Posted March 7, 2010 Share Posted March 7, 2010 $fh=fopen($myFile, 'w') or die("can't open file"); fclose($fh); Since you do not define the directory there that creates an empty file where ever this script is executing from. To fix, remove that (as I do not see that it is doing anything productive) or unlink($myFile); as well. Either or should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/194429-unlink-let-callit-some-kind-of-trouble/#findComment-1022723 Share on other sites More sharing options...
regoch Posted March 7, 2010 Author Share Posted March 7, 2010 Working! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/194429-unlink-let-callit-some-kind-of-trouble/#findComment-1022739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.