how ca i make a php function to delet a photo


this is the file theat show photos ....

<?php 
$dir="../SV_uplod/";
if($opendir = opendir($dir))
{
while(($file = readdir($opendir)) !==FALSE)
{
if($file!="."&&$file!="..")
echo "<img src='$dir$file' width='200'><br>",$dir,$file;
}
}
?>

Please Help THX !

The function you want is unlink.

Plenty of info on the PHP site. And plenty of tutorials available online if you search for them :)

wat in this code is right i get error mesage ...

Warning: unlink() expects parameter 2 to be resource, string given in E:\home\test\www\Administrator\pages\sv.php on line 72

<form action="member.php?page=1" method="post">
<?php
include "sec/db.php"
$result = mysql_query("SELECT * FROM SV ORDER BY id DESC");
while($row = mysql_fetch_array($result))
{
$img = $row["new_file_name"];
$name = $row["numele"];
$zi = $row["zi"];
$luna = $row["luna"];
$an = $row["an"];
$locu_de_trai = $row["locul_de_trai"];
$armata = $row["armata"];
$familie = $row["familie"];
$copii = $row["copii"];
printf ("

<table border='1' align='center'>
  <tr>
    <td><img src='../../SV_uplod/$img'width='200'></td>
    <td>
	<table border='0'>
  <tr>
    <td>Name : $name </td>
  </tr>
  <tr>
    <td>Birthday : $zi  $luna  $an</td>
  </tr>
  <tr>
    <td>Where lives now  :  $locu_de_trai</td>
  </tr>
  <tr>
    <td>
<table border='0'>
  <tr>
    <td>Army : $armata / </td>
    <td>Family : $familie / </td>
    <td>Children : $copii</td>
  </tr>
</table>
</td>
  </tr>
</table>
</td>
    <td>
<table border='0'>
  <tr>
    <td><input name='id' type='radio' value='%s'></td>
  </tr>
  <tr>
    <td><a href=''><img src='photo/read.png' border='0' ></a></td>
  </tr>
</table>
	</td>
  </tr>
</table>
",$row["id"]
) ;}
?>
<center><input name="submit" type="submit" value="Удалить заметку!!!">
</center></form>
<?php
if (isset($_POST['id'])){$id = $_POST['id'];} 
mysql_connect("localhost","danvrajmas","nokia3110");
mysql_select_db("test");
	 
if (isset($id))
{
$dir = "SV_uplod/";
$result = mysql_query ("DELETE FROM SV WHERE id='$id'");
if ($result == 'true') {unlink($dir,$img);  echo "<center><p><b>Ваша заметка успешно удалена!</b></p></center>",$dir,$img;}
else {echo "<p>Ваша заметка не удалена!</p>";}
}?>

wat in this code is right i get error mesage ...

Warning: unlink() expects parameter 2 to be resource, string given in E:\home\test\www\Administrator\pages\sv.php on line 72

<form action="member.php?page=1" method="post">
<?php
include "sec/db.php"
$result = mysql_query("SELECT * FROM SV ORDER BY id DESC");
while($row = mysql_fetch_array($result))
{
$img = $row["new_file_name"];
$name = $row["numele"];
$zi = $row["zi"];
$luna = $row["luna"];
$an = $row["an"];
$locu_de_trai = $row["locul_de_trai"];
$armata = $row["armata"];
$familie = $row["familie"];
$copii = $row["copii"];
printf ("

<table border='1' align='center'>
  <tr>
    <td><img src='../../SV_uplod/$img'width='200'></td>
    <td>
	<table border='0'>
  <tr>
    <td>Name : $name </td>
  </tr>
  <tr>
    <td>Birthday : $zi  $luna  $an</td>
  </tr>
  <tr>
    <td>Where lives now  :  $locu_de_trai</td>
  </tr>
  <tr>
    <td>
<table border='0'>
  <tr>
    <td>Army : $armata / </td>
    <td>Family : $familie / </td>
    <td>Children : $copii</td>
  </tr>
</table>
</td>
  </tr>
</table>
</td>
    <td>
<table border='0'>
  <tr>
    <td><input name='id' type='radio' value='%s'></td>
  </tr>
  <tr>
    <td><a href=''><img src='photo/read.png' border='0' ></a></td>
  </tr>
</table>
	</td>
  </tr>
</table>
",$row["id"]
) ;}
?>
<center><input name="submit" type="submit" value="Удалить заметку!!!">
</center></form>
<?php
if (isset($_POST['id'])){$id = $_POST['id'];} 
mysql_connect("localhost","danvrajmas","nokia3110");
mysql_select_db("test");
	 
if (isset($id))
{
$dir = "SV_uplod/";
$result = mysql_query ("DELETE FROM SV WHERE id='$id'");
if ($result == 'true') {unlink($dir,$img);  echo "<center><p><b>Ваша заметка успешно удалена!</b></p></center>",$dir,$img;}
else {echo "<p>Ваша заметка не удалена!</p>";}
}?>

Of course you are using the wrong syntax. There should be only one argument which refers to the file name/path to file name.

Thx guy's I LOVE THIS WEB SITE :D

guy's way i can not execute like this ?

<?php
echo exec('SV/546463748.png');
$url="member.php";
$timeout_minutes = 0;
$timeout_seconds = 1;
sleep($timeout_seconds + $timeout_minutes * 60);
header ('Location: '.$url);
exit;
?>

but if is like this the script worcks

<?php
echo exec('546463748.png');
$url="member.php";
$timeout_minutes = 0;
$timeout_seconds = 1;
sleep($timeout_seconds + $timeout_minutes * 60);
header ('Location: '.$url);
exit;
?>

thx

Executing a image file?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.