What did you do to cause this?
Steps to reproduce:
What page were you on?
What PHP and MySQL versions do you run?
PHP version 5.3.23, MySQL version 5.5.27-cll
Describe the defect:
$project->next_tid increments twice: one time at the first submit and other time after the correction of the error.
Possible solution: to check for errors before making the $next_tid++ and if there are any, don't increment it.