[thelist] PHP deleting a file

Christian Heilmann codepo8 at gmail.com
Wed Oct 12 06:35:56 CDT 2005


On 10/12/05, Liam Delahunty <liam at megaproducts.co.uk> wrote:
> On 12/10/05, Jeremy Weiss <jweiss at cox-internet.com> wrote:
> > I'm needing some help with the following PHP script. I'm trying to check and
> > see if $oldphoto is equal to nophoto.gif. It if is equal I want it to do
> > nothing. Otherwise I want it to delete $oldphoto. The problem is, it deletes
> > $oldphoto either way.
> >
> >   if ($oldphoto != "nophoto.gif") {
> >     // Delete the agents existing photo
> >     @unlink("$oldphoto");
> >   }
> >
>
> Does nophoto.gif exist?
>
> Have you tried the full path to the image?
>
> What errors do you get if you remove the error suppression? (@)

and why nest a variable in quotationmarks?
I think your problem is the $oldphoto value. If it is not set, then it
will also delete the file.


More information about the thelist mailing list