Hi! Ive tried to change the script sometimes now and it still dont work... i still get the error Warning: unlink() failed (No such file or directory) and it wont remove the data form the database....
$dir_to_upload is defined in config.php wich is included... it works just fine to display image using echo "<img src='$dir_to_upload/$row->Photo'> $Photo is defined in the following tag in the form <input type=hidden name='Photo' value='<?=$row->Photo?>'> the variable $id is defined in the following tag in the form <input type=hidden name='id' value='<?=$row->ID?>'> the code i use is: the delete function and update database... // ---------------------- delete image --------------------- if (isset($delimage)) { $result=unlink('$dir_to_upload/$row->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 "Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] At 16:03 26.02.2003, Jøran Sørbø spoke out and said: --------------------[snip]-------------------- > 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"; > } > > } > >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 --------------------[snip]-------------------- 1) You do not define $dir_to_upload, nor $Photo (at least in your example) - this would lead to $result=unlink('/'); hence error 1. 2) You don't define the variable $id (at least in your example), so the SQL statement would read "update product set " . "Photo='nothing', miniPhoto='nothing', picture='0' " . "where ID=" hence error 2 (after "ID="). If these values are available on a global level, you must declare them global within your function. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php