keep in mind, i'm not testing this code.. just use it for a logic reference.. most of it should work though.
Code:
$sql = "CREATE TABLE images (
`imageid` int(10) unsigned NOT NULL auto_increment,
`filename` varchar(32) NOT NULL default '',
`caption` varchar(64) NOT NULL default '',
PRIMARY KEY (`imageid`),
UNIQUE KEY `filename` (`filename`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;";
this table will automatically increment the ID so you don't have to insert the id when you add an image. it's not necessary to have that field but i prefer to handle individual elements of a table with an integer.
the filename is unique, so you won't be able to have duplicate entries for a filename. since all your files are in the same upload directory, that's probably best.
keep in mind, there's a lot of ways to do what you're doing .. i'm just posting one way to help you get something up so you can tweak it to your needs.