What are the potential pitfalls of using mysql_pconnect in PHP?

Using mysql_pconnect in PHP can lead to connection pooling issues and potential performance degradation due to the persistent nature of the connections. It can also result in resource exhaustion on the database server if not managed properly. To avoid these pitfalls, it is recommended to use mysql_connect or mysqli_connect with proper connection handling and resource management.

// Connect to MySQL using mysqli_connect with proper connection handling
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// Perform database operations here

// Close connection
mysqli_close($conn);