0) { while($stubcount = mysql_fetch_row($stubquery)) { $count = $stubcount[0]; if ($count > 0) { $stub .= "-$count"; $count++; } } } $stub_f = mysql_real_escape_string($stub); $sql = "INSERT INTO photos (Title, DateCreated, File, Public, Stub) VALUES ('$photoTitle_f', '$dateCreated', '$fileName_f', $isPublic, '$stub_f')"; if (!$add = @ mysql_query ($sql, $connection)) logerror(); $sql = "SELECT MAX(PhotoID) AS MaxID FROM photos"; if (!$maxid = @ mysql_query ($sql, $connection)) logerror(); while($thisMaxID = mysql_fetch_row($maxid)) { $photoID = $thisMaxID[0]; } return $photoID; } ?>