Removed the SQL close function, also started closing the sql conection after each query.  I may revist this later, as I am unsure how to keep the connection going.  Maybe set it to a global variable so that it can be tracked through the code.  But for now I just close the SQL connection and reopen it.
Updated DocIP to use the new SQL query fuctions.  This gives me more control over how queries are executed.  Mainly I switched over because it worked well for my PHP pages.  Although the functions don't quite map together perfectly, but close enough