Forum Moderators: coopster

Message Too Old, No Replies

unlink file problem

         

lazarus

7:55 pm on Jun 14, 2003 (gmt 0)

10+ Year Member



hi,

this is a really silly problem, but its driving me mad. the short of it is i have a database which holds the filename of images on my server, as well as press releases. when the admin deletes a post, i want the releven pic's deleted from the server, and its giving me hell. i dont think its beacuse i am on a windows box cause i can specify a specific file for it to delete fine, its just when it has to pull the name from a database. any ideas?

 
// generate and execute query
$pic=$_get['pic'];
$id= $_GET['id'];
$query = "DELETE FROM news WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$file="../keith-robinson_news/images/".$pic;
unlink ($file);

NameNick

8:49 pm on Jun 14, 2003 (gmt 0)

10+ Year Member



Lazarus,

I would avoid relative paths like your $file="../keith-robinson_news/images/".$pic;

Absolute paths from the server root often solve path problems.

NN

DrDoc

12:37 am on Jun 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$pic=$_get['pic'];

should be

$pic=$_GET['pic'];

lazarus

8:45 am on Jun 15, 2003 (gmt 0)

10+ Year Member



i dont think its the path, as when i put in:

$file="../keith-robinson_news/images/dave.jpg";

dave.jpg is deleted with no probs.

thx for pointing out the 'get' 'GET' problem. happens after so many hours staring blankley at code. :)

BCMG_Scott

2:31 pm on Jun 16, 2003 (gmt 0)

10+ Year Member



What is the value of $pic? Could be that pic has some extra data (such as a preceeding slash)?

Scott Geiger