<?php
mysql_connect("your.server.com","username","password");
mysql_select_db("database_name");
$query = "DELETE FROM uploads where id=$id";
$delete = MYSQL_QUERY($query);
print "File ID $id has been removed from the database";
?>
Like our previous code that downloaded files, this script allows files to be removed just by typing in their URL: http://yoursite.com/remove.php?id=2 (replace 2 with the ID you want to remove.) For obvious reasons, you want to be careful with this code. This is of course for demonstration, when we actually build applications we will want to put in safeguards that ask the user if they are sure they want to delete, or perhaps only allow people with a password to remove files. This simple code is the base we will build on to do all of those things.

