Small fixes

This older code is intended for people still using mysqli in their PHP.
This just fixes some old bugs and duplicate functions.