Hi!

Im developing a site using php and mysql and need som help...
The site is a simple company site and it gets products, pictures etc from
the database...
Everyhing worls great except deleting product images from the database,
and unlink them from the directory...

the code i use is:
the delete function and update database...

// ---------------------- delete image ---------------------
 if (isset($delimage))
 {

$result=unlink('$dir_to_upload/$Photo');

       $result=mysql_query("
        update product set
         Photo='nothing',
   miniPhoto='nothing',
   picture='0'
         where ID=$id
         ") or die (mysql_error(). " : ".mysql_errno());

       if ( ($result) != 1)
       print "Sorry,can't delete the image ";
        else
        {
         print "Image was deleted sucsessfully.<br>If you want to upload a
new image do it now,overwise close the window";
         }

 }

//----- end delete image -----------

the code to use it...

<?
 if ($row->picture == '1')
 echo "<img src='$dir_to_upload/$row->Photo'>
<br>
<form action=one_product.php name='imagedelete' method='post'>
<input type=hidden name=delimage>
<input type=hidden name='Photo' value='<?=$row->Photo?>'>
<input type=hidden name='miniPhoto' value='<?=$row->miniPhoto?>'>
<input type=hidden name='picrue' value='<?$row->picture?>'>
<input type=hidden name=id value='<?=$row->ID?>'>
<table align=center width=200>
<tr>
<td align=center>
<br>
</td>
</tr>
   <tr><td align=center><input type=submit name=submit value='Delete image'
onclick=javascript:return del()></td></tr>
</table></form>";

else echo "Det er ikke laggt ut no bilde til dette produktet.<br>
<a href='upload2.php?lastid=$row->ID'>Klikk her for å legge til bilde</a>
";
?>

but when i execute this, i get the following error...

Warning: unlink() failed (No such file or directory) in one_product.php on
line 178
You have an error in your SQL syntax near '= ' at line 6 : 1064

can anyone please help me with this??
I would also like som help regarding unlinking multiple images...
So that it deletes both the original photo and the thumbnail...

Best regards,
Jøran Sørbø :: Norway



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to