What are the potential pitfalls of using a simple file-based storage system for forum posts instead of a MySQL database?

One potential pitfall of using a simple file-based storage system for forum posts instead of a MySQL database is the lack of scalability and performance. File-based systems can become slow and inefficient as the number of posts increases, making it difficult to search and retrieve data quickly. To solve this issue, you can switch to using a MySQL database to store forum posts, which offers better performance, scalability, and data management capabilities.

// Connect to MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "forum";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}