What is the significance of properly escaping characters like '\n' in SQL statements when dealing with file uploads in PHP?

When dealing with file uploads in PHP, it is important to properly escape characters like '\n' in SQL statements to prevent SQL injection attacks. This can be done using prepared statements or by using functions like mysqli_real_escape_string to escape special characters before inserting them into the database.

// Assuming $fileContent contains the file content to be inserted into the database
$fileContent = mysqli_real_escape_string($conn, $fileContent);

// Insert the escaped file content into the database
$sql = "INSERT INTO files (content) VALUES ('$fileContent')";
$result = mysqli_query($conn, $sql);

if ($result) {
    echo "File content successfully inserted into the database.";
} else {
    echo "Error inserting file content into the database.";
}