yongfook
05-08-2005, 11:55 AM
Woohoo, first post! Been a long time unregistered lurker of these forums - this place has solved my coding problems a number of times. But here's one I can't seem to find an answer for...
//find what the oldest record is in the table
$getoldestfile = "SELECT * FROM mytable WHERE id>1 LIMIT 1";
$oldfile=mysql_query($getoldestfile);
$byebye=mysql_result($oldfile, 0, "url");
//and delete the file from the server
unlink("images/$byebye.jpg");
//then get rid of the oldest entry
$deleteoldestrecord = "DELETE FROM mytable WHERE id>1 LIMIT 1";
mysql_query($deleteoldestrecord);
Something is wrong with the above script. I know the queries are working so actually I think it is a problem with my php (so perhaps this should have gone in the php forum? sorry!).
Basically I get the name of a file from the table, then delete it from my server. Everything works apart from the file delete - I think maybe I am using mysql_query and mysql_result incorrectly.
Any help appreciated!
YF
//find what the oldest record is in the table
$getoldestfile = "SELECT * FROM mytable WHERE id>1 LIMIT 1";
$oldfile=mysql_query($getoldestfile);
$byebye=mysql_result($oldfile, 0, "url");
//and delete the file from the server
unlink("images/$byebye.jpg");
//then get rid of the oldest entry
$deleteoldestrecord = "DELETE FROM mytable WHERE id>1 LIMIT 1";
mysql_query($deleteoldestrecord);
Something is wrong with the above script. I know the queries are working so actually I think it is a problem with my php (so perhaps this should have gone in the php forum? sorry!).
Basically I get the name of a file from the table, then delete it from my server. Everything works apart from the file delete - I think maybe I am using mysql_query and mysql_result incorrectly.
Any help appreciated!
YF