Why is it not recommended to store PHP code in a database?

Storing PHP code in a database is not recommended because it can introduce security vulnerabilities and make it difficult to maintain and debug the code. Instead, it is better to store data in the database and use PHP to retrieve and manipulate that data.

// Example of retrieving data from a database and using it in PHP code
$conn = new mysqli($servername, $username, $password, $dbname);

$sql = "SELECT * FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Name: " . $row["name"]. " - Email: " . $row["email"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();