Jump to content

unlink error


gabrielkolbe

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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.