What best practices should be followed when including external PHP files in a project to avoid MySQL connection issues and potential security vulnerabilities?

When including external PHP files in a project, it is important to ensure that you do not establish a new MySQL connection in every included file, as this can lead to connection issues and potential security vulnerabilities. Instead, you should establish a single database connection in a separate file and include that file in all other PHP files that require database access. This practice helps to avoid unnecessary connections and improves code maintainability and security.

// db_connection.php

$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);
}
```

In your other PHP files, you can include the `db_connection.php` file at the beginning to access the existing database connection:

```php
// other_file.php

include 'db_connection.php';

// Use $conn for database queries