I don’t really know anything about mysqli yet, so I can’t offer much help there. This sounds a little bit like there is a possibility that your inserts aren’t getting committed, which would result in the transaction rolling back. Not sure why the last insert succeeds, but maybe the close operation explicitly commits that one or something. You may want to take a look and see if auto_commit is enabled.
It seems to me that making this thing work is more important than the exact method used. What about using the arrays you generated with relevent data to build a multiple record insert statement, and just executing an old fashioned insert statement?
INSERT INTO ziplonglat (zipID,zipCode,zipLongitude,zipLatitude,zipRLatitude,zipRLongitude,zipcodetest)