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.
mysqli_close($connection)
$connection
Check connection errors. mysqli_connect() always returns a MySQLi object.
use this:
$mysqli_connection = new MySQLi('localhost', 'user', 'pass', 'db'); if ($mysqli_connection->connect_error) { echo "Not connected, error: " . $mysqli_connection->connect_error; } else { echo "Connected."; }