What are some potential pitfalls to be aware of when outputting database data in PHP, especially in terms of formatting and line breaks?

When outputting database data in PHP, especially when dealing with text fields, it's important to be mindful of special characters and line breaks that may disrupt the formatting of the output. To ensure proper formatting, use the `nl2br()` function to convert newline characters to HTML line breaks before displaying the data.

// Fetch data from the database
$data = $row['text_field'];

// Output the data with line breaks converted to <br> tags
echo nl2br($data);