Hello again, I will try and explain this as simply as possible.
I have some pages I have been working on
I have a form that inserts info into a databse and uploads an image to an upload directory all of this works fine.
I finished coding the function to delete the selected row.
I have done a massive search and found a few sites using “unlink() function”.
I dont quite understand how to use this function.
could one (or more) of you more advanced coders assist me in deleting the image linked to the row when the “delete” link is selected to delete the row.
here is the code for the upload form I use.
[code=php]
<?php
$uploadpath = ‘../uploads/’;
$source = $HTTP_POST_FILES[‘image’][‘tmp_name’];
$dest = ”;
// if page is not submitted to itself echo the form
if (!isset($_POST[‘scam’]))
{
?>
<form action=”<?php echo $PHP_SELF;?>” method=”post” enctype=”multipart/form-data” name=”scam” id=”scam”>
<center>
<font color=”#0000FF” size=”-1″>Upload a screen shot of the scam in progress</font>
<br>
<b>Screen Shot:</b> <font color=”#FF0000″>*</font>
<input name=”image” type=”file” id=”image” size=”32″>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”96000″>
<div align=”center”>
<input type=”submit” name=”scam” value=”Submit”>
<input name=”reset” type=”reset” class=”liteoption” value=”RESET” />
</div>
</form>
<?
} else {
if ( ($source != ‘none’) && ($source != ” )) {
$imagesize = getimagesize($source);
switch ( $imagesize[2] ) {
case 0:
die (“Image unknown, must be gif, jpg, or png ONLY!”);
break;
case 1:
$dest = $uploadpath.uniqid(‘img’).’.gif’;
break;
case 2:
$dest = $uploadpath.uniqid(‘img’).’.jpg’;
break;
case 3:
$dest = $uploadpath.uniqid(‘img’).’.png’;
break;
}
if ( $dest != ” ) {
if ( move_uploaded_file( $source, $dest ) ) {
chmod($dest, 0644);
} else {
die (“Unable to store image!”);
}
}
} else {
die (“No image was selected!”);
}
$image = $dest;
$query = “INSERT INTO “. scams .”
(scam_image) VALUES
(‘”.$image.”‘)”;
$result = mysql_query($query) or die (“Error retrieving data!”);
{
echo “scammer_created_succesfully!”;
}
}
?>
Here is the code I use for outputing the query as well as delete the row:
[code=php]
<h1 align=”center”><b>Scammer Admin Area</b></h1>
<div align=’right’><A HREF=”<? echo $PHP_SELF ?>?action=logout”>Logout</A></div><br />
<table width=”98%” border=”1″ align=”center” cellpadding=”0″ cellspacing=”0″ bordercolor=”#c0c0c0″>
<br />
<br />
<tr>
<td width=”5%” nowrap=”NOWRAP”> <h3 align=”center”><b>Delete</b></h3></td>
</tr>
<tr>
<?php
$query = “SELECT * FROM scams ORDER by scam_id”;
$result = mysql_query($query) or die (“Error in query: $query. “.mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0)
{
// yes print them one after another
while($row = mysql_fetch_array($result)) {
$id = $row[‘scam_id’];
echo “<td width=’5%’ align=’center’><div align=’center’><a href=’$PHP_SELF?cmd=delete&scam_id=$row[scam_id]’>Delete</a></div></td>”;
echo “</tr>”;
}
} else {
// no print status message
echo “<tr>”;
echo “<td COLSPAN=9 width=’100%’ align=’center’><b>No Scammers Have been listed at this time</b></td>”;
echo “</tr>”;
}
?>
</table>
<?php
if($_GET[“cmd”]==”delete”)
{
$scam_id = $HTTP_GET_VARS[‘scam_id’];
$query = “SELECT * FROM scams ORDER by scam_id;
$result = mysql_query($query) or die (“could not select!”);
$query = “DELETE FROM scams WHERE scam_id = $scam_id”;
$result = mysql_query($query) or die (“could not delete!”);
?>
Thank you for your time
I do have a test area set up please pm me if you need the link
**had to remove much of my code due to limitations here (my scripts were over the 10000 limit ? )