Jump to content

Archived

This topic is now archived and is closed to further replies.

gabrielkolbe

unlink error

Recommended Posts

I have a website where people can add and delete pictures. All worked fine, untill recently..out of the blue. I get error messages when trying to delete a picture..

[quote]Warning: unlink(../logos/): Is a directory in /home/gabriel/public_html/include_cs/functions.php on line 1710[/quote]

Here is the script..

[code] $query="SELECT * FROM business_site2 WHERE user_id = '".$_SESSION['user_id']."'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_object($result)) { unlink("../logos/".$row->photo1); }code]

I checked the php manual but can not see where the problem lays..anyone any ideas?[/code]

Share this post


Link to post
Share on other sites
What it looks like is that somehow "$row->photo1" is blank. I would put the unlink into an "if" statement:
[code]<?php
$query="SELECT * FROM business_site2 WHERE user_id = '".$_SESSION['user_id']."'";
$result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());
while ($row = mysql_fetch_object($result)) {
              if ($row->photo1 != '') unlink("../logos/".$row->photo1);
              else echo 'Error: there is something wrong, the name of the photo is all blank (' . $row->id . ')<br>';
        }
?>[/code]
I'm assuming you have a field called "id" in the table, so you can go look at the record afterwards.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.