Last insert id producing 0 in few enteries

As @mabismad mentioned in the other thread, you’re not checking to see whether your first query has executed, getting an insert-id of zero suggests that it did not.