fixed bad definition of InsertLog function and calling last id from db