What are the potential security risks of storing passwords in plaintext within mysql_connect()?

Storing passwords in plaintext within mysql_connect() poses a significant security risk as anyone with access to the code can easily view the password. To mitigate this risk, it is recommended to store the password in a separate configuration file outside of the web root directory and include it in your PHP script.

// config.php
<?php
$hostname = 'localhost';
$username = 'root';
$password = 'your_password';
$database = 'your_database';
?>

// index.php
<?php
include 'config.php';

$conn = mysqli_connect($hostname, $username, $password, $database);

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

echo "Connected successfully";
?>