Added integer check on SQL insertion, and a check that we aren't trying to insert too many values.
Oops