Never create a new connection for every query; You don’t even have to close it manually.
Just create the connection at the beginning of you page
have a look at: How do you efficiently connect to mysql in php without reconnecting on every query
you can use this:
public function __destruct()
{
mysql_close($this->connection);
}
it will get called when the page is closed