I am going to use mysqli_close($connection)
to close the $connection
. But Before Closing I need to ensure that the concerned connection is open.
Try this:
function close_connection(){
$thread = $mysqli->thread_id;
$mysqli->close();
$mysqli->kill($thread);
}
That will close the connection you opened using object oriented style like this:
$mysqli = new mysqli($db_server, $db_username, $db_password, $db_name);
That's the basic idea, but if you're using the procedural style, I'm sure you'll be able to custom the code as you need.