Im having some problem in deleting an image from the source folder and from the database[DB], well i guess u can help me with this
Database Schema:
manage_pic {pic_id, filename, info}
<?php
include("validate_session.php");
$loginname=$_SESSION["loginname"];
include("database_connection.php");
$pic_id=$_GET['picid']; //getting this from a previous page
$query = mysql_query("SELECT * FROM manage_pic WHERE pic_id='$pic_id'");
if(!$query) // if cannot retrieve, display error message
{
die('ERROR: Could not RETRIEVE DATA from table. ' . mysql_error());
}
$result = mysql_fetch_array( $query );
if(!$result) // if cannot retrieve, display error message
{
die('ERROR: Could not RETRIEVE DATA from table. ' . mysql_error());
}
$info= $result['info'];
$prod_serv_name= $result['prod_serv_name'];
mysql_close($con);
?>
<html>
<head>
<title>.</title>
<script language="Javascript">
<!--
function confirmDelete()
{
input_box=confirm("Are you sure you want to delete all content of this category?");
if (input_box==true)
{
// Output when OK is clicked
window.location.replace("delete_pic_pro.php?picid=<?php echo "$pic_id"; ?>")
}
else
return false;
}
-->
</script>
</head>
<body>
<div align="center" id="error" >
<?php
if (isset($_SESSION['error']))
{
echo $_SESSION['error'];
unset($_SESSION['error']);
}
?>
</div>
<?php
echo "<img src=\"../content_images/" . $result['filename'] . "\" alt=\"\" />";
?>
</body>
</html>
Next page[i.e the processing page]delete_pic_pro.php
<?php
include("validate_session.php");
$loginname=$_SESSION["loginname"];
include("database_connection.php");
$pic_id=$_GET['picid'];
//echo "$pic_id";
$sql_delete="DELETE FROM manage_pic WHERE pic_id=$pic_id";
unlink($filename);
header("Location: admin_show_content.php");
if(!$sql_delete) // if cannot retrieve, display error message
{
die('ERROR: Could not DELETE DATA from table. ' . mysql_error());
$_SESSION['error'] = "A problem occurred, cannot delete.";
header("Location: admin_edit_content.php?picid='$pic_id'");
}
mysql_close($con);
?>
Problem:
The problem im getting is that the picture is not being deleting from the image/source folder and not even in the database
Can u please tell me if im using the unlinck function right or even the delete query if its ok.. i cant find the problem myself
Thx
Note: Some parts of the code like basic HTML have been omitted for simplicity purposes
This post has been edited by Jupiter: 28 August 2009 - 11:22 AM

New Topic/Question
Reply




MultiQuote




|