You don't have to close the connection after every query, you can open it once at the beginnen ald close it just before your script exits.
Be very carefull with pconnect, it will keep connections open even after your scripts have stopped. This means the total number of open connections increases dramatically and on a shared server it can easily overload the database server and cause the infamous 'too many connections' error.
Do not use it unless you know what you are doing!