What is the common SQL syntax error that occurs when trying to load multiple CSV files into a MySQL database using PHP?

When trying to load multiple CSV files into a MySQL database using PHP, a common SQL syntax error that occurs is trying to use the `LOAD DATA INFILE` command for each file separately. This command is not designed to handle multiple files in one query. To solve this issue, you can loop through the list of CSV files and execute the `LOAD DATA INFILE` command for each file individually within the loop.

<?php

$files = ['file1.csv', 'file2.csv', 'file3.csv'];

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

foreach ($files as $file) {
    $sql = "LOAD DATA INFILE '$file' INTO TABLE table_name FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 LINES";
    
    if ($conn->query($sql) === TRUE) {
        echo "File $file loaded successfully<br>";
    } else {
        echo "Error loading file $file: " . $conn->error . "<br>";
    }
}

$conn->close();

?>