Re: [PHP] unlink problem... please help...

2003-02-26 Thread Chris Hayes
At 16:42 26-2-03, you wrote:
$result=unlink('$dir_to_upload/$row->Photo');
what do you get when you echo

echo htmlspecialchars('$dir_to_upload/$row->Photo');

and do you use the full file path? Images accept relative links but in my 
experience PHP's file handling functions want the full path. 

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


Re: [PHP] unlink problem... please help...

2003-02-26 Thread Ernest E Vogelsinger
At 16:42 26.02.2003, Jøran Sørbø spoke out and said:
[snip]
>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 "src='$dir_to_upload/$row->Photo'>
>$Photo is defined in the following tag in the form name='Photo' value='Photo?>'>
>
>
>the variable $id is defined in the following tag in the form type=hidden name='id' value='ID?>'>
[snip] 

There are also errors in how you format the filename passed to unlink(),
and in formatting the SQL statement - see below.
Do yourself a favour and make the following modification to your script and
look at the output:

if (isset($delimage))
{
   $file = "$dir_to_upload/{$row->Photo}";
$sql = "update product set Photo='nothing', miniPhoto='nothing', " .
   "picture='0' where ID='$id'";

echo "unlink($file);query($sql);";

$result=unlink($file);
   $result=mysql_query($sql) or die 


-- 
   >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



Re: [PHP] unlink problem... please help...

2003-02-26 Thread Jøran Sørbø
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



Re: [PHP] unlink problem... please help...

2003-02-26 Thread Ernest E Vogelsinger
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



[PHP] unlink problem... please help...

2003-02-26 Thread Jøran Sørbø
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.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



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