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 "
$Photo is defined in the following tag in the form
the variable $id is defined in the following tag in the form
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.If you want to upload a
new image do it now,overwise close the window";
}
}
//- end delete image ---
the code to use it...
picture == '1')
echo "
";
else echo "Det er ikke laggt ut no bilde til dette produktet.
Klikk her for å legge til bilde
";
?>
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.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