How can the absence of a mysql_close() function call affect the execution of PHP scripts with MySQL connections?

When the mysql_close() function is not called, it can lead to resource leaks as the connection to the MySQL server remains open even after the script has finished executing. This can result in potential performance issues and may exhaust the available connections if not managed properly. To solve this issue, it is important to explicitly close the MySQL connection using mysql_close() at the end of the script.

// Establish connection
$connection = mysql_connect("localhost", "username", "password");

// Select database
mysql_select_db("database", $connection);

// Perform queries

// Close connection
mysql_close($connection);