What are the potential issues with using the mysql_connect function in PHP for database connections?
The mysql_connect function is deprecated in newer versions of PHP and is not recommended for use due to security vulnerabilities and lack of support. It is recommended to use the mysqli or PDO extension for database connections in PHP.
// Using mysqli extension for database connection
$servername = "localhost";
$username = "username";
$password = "password";
$database = "dbname";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}