Hey I'm working on a site for an auto wrecker. They want a complete administrative part to the website where they can add trucks and also remove them. I've finished the 'add' part, where they put in all the details and a picture, which is uploaded, then a thumbnail is made from the picture and both are used in the site. The problem I'm having now is with the 'delete' part. I've figured out this code so far, but I just get a blank page:
Code: Select all
if(cmd == "delete")
{
$sql = "DELETE FROM usedtrucks WHERE id=$id";
echo "110";
$result = mysql_query($sql) or die("error");
echo "112";
$pichandle = fopen("/image/usedtrucks/$id.jpg", 'w') or die("Can't open file $id.");
echo "114";
fclose($pichandle);
echo "116";
unlink("/image/usedtrucks/$id.jpg");
echo "118";
$thumbhandle = fopen("/image/usedtrucks/thumb/$id.jpg", 'w') or die("Can't open thumbnail $id.");
fclose($thumbhandle);
unlink("/image/usedtrucks/thumb/$id.jpg");
echo "Entry, image and thumbnail deleted successfully.<br><a href=\"edit_usedtrucks.php\">Back</a>";
}
The link to delete a post is also in edit_usedtrucks.php, and goes to: edit_usedtrucks.php?cmd=delete&id=$id. Is there just a setting problem or is it something else that I'm not doing right? thanks