What are the potential pitfalls of using the outdated mysql_connect function in PHP for database connections?
Using the outdated mysql_connect function in PHP for database connections can pose security risks as it is deprecated and no longer supported in newer PHP versions. It is recommended to use mysqli or PDO for database connections to ensure better security and compatibility with current PHP versions.
// Using mysqli for database connection
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}