in reply to How to find the highest number in a mysql table
my $dbh = DBI->connect(...);
my $next_pic = $dbh->selectrow_hashref("SELECT MAX(image_id)+1 AS nextid from images")->{'nextid');
Supposing that your table is called 'images' and the autoincrement column name is 'image_id'.