one.time.loser Posted December 10, 2006 Share Posted December 10, 2006 My brain hurt from the following snippet, i've been cramming php/mysql for 2 weeks now with many headaches on the way. Gone from Zero to Hero, now back to Zero. Imagine a 5 field table;1. Id //Nuff Said2. Submitted //TimeStamp3. Title //Duh4. Description //Double Duh5. Image //Image Name URLIt use to be only 4 , with image being a new field. The old way of removing old records was;$sql = mysql_query("DELETE from free where submitted < date_sub(now(), interval (8) day)") or die(mysql_error());Now i tried writing it like this;if($action=='delete') { $image_dir="./admin/images/"; //Deleting image from directory $sql = mysql_query("SELECT from free where submitted < date_sub(now(), interval (8) day)") or die(mysql_error()); $row = mysql_fetch_row($query); $image=$row[image]; $image_dir.=$image; chmod($image_dir,0777); if (file_exists($image_dir)) { unlink($image_dir);// or die ("Could not delete file"); } $sql = mysql_query("DELETE from free where submitted < date_sub(now(), interval (8) day)") or die(mysql_error()); }As i am a member of 8 different forums now, i haven't got a definitive answer yet. So the learning curve is currently running down hill at a 90 degree angle. Where i went wrong, i have no idea, only because i really dont have much to go on.Pls take the time someone and show me where i went wrong, and if not! Then get me some COFFEE please! Quote Link to comment Share on other sites More sharing options...
Crusader Posted December 10, 2006 Share Posted December 10, 2006 What's the error you're getting? Quote Link to comment Share on other sites More sharing options...
Zane Posted December 10, 2006 Share Posted December 10, 2006 yes, it would help if you described what it's NOT doingand what it should be doing.give any errors Quote Link to comment Share on other sites More sharing options...
one.time.loser Posted December 11, 2006 Author Share Posted December 11, 2006 There are no visible errors, the record gets deleted yet the image is still on the server. The image path is correct and the attributes of the folder. This is my first attempt at writing a script to query the table for an expired record, then delete the image, then delete the record. If the formatting of the above is correct please let me know, it may be an entirely different problem. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 15, 2006 Share Posted December 15, 2006 Don't you mean SELECT *? And if the record is delete, this is a file system issue... Quote Link to comment 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.