Click to See Complete Forum and Search --> : Unlink problems


Ash
08-27-2003, 05:26 AM
I've written an archive function that looks through a database of filenames and deletes anything older than a certain date. My code goes :

$result=mysql_query("SELECT filename FROM gallery WHERE date < $gallerylimit",$link);
while ($row=mysql_fetch_array($result)) {
unlink ("../../gallery/thumbs/".$row['filename']);
unlink ("../../gallery/images/".$row['filename']);
}

But I get errors for the unlink commands. Am I allowed to use the '../../' format, or do I have to use an absolute pathname ?

Which PHP command diaplays the full pathname ?


Cheers,
ASh

pyro
08-27-2003, 07:31 AM
You need to use a root path. You can use $_SERVER['DOCUMENT-ROOT'] to get your document root, and from there, you will be able to know the path.

http://us4.php.net/manual/en/function.unlink.php
http://us4.php.net/manual/en/wrappers.php