PHP File manipulation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

PHP File manipulation

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$cmd instead of cmd ?
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

Post by paqman »

:oops: hehehe... god I always do things like this. Thanks!
Post Reply