Page 1 of 1

PHP File manipulation

Posted: Mon Sep 05, 2005 2:11 am
by paqman
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

Posted: Mon Sep 05, 2005 2:22 am
by feyd
$cmd instead of cmd ?

Posted: Mon Sep 05, 2005 2:26 am
by paqman
:oops: hehehe... god I always do things like this. Thanks!