What potential pitfalls should be considered when storing HTML code in a database using PHP?

When storing HTML code in a database using PHP, it's important to consider the potential pitfalls of SQL injection attacks. To prevent this, you should always sanitize the HTML code before inserting it into the database. Use prepared statements with parameterized queries to securely insert the HTML code.

// Sanitize HTML code before inserting into the database
$htmlCode = htmlspecialchars($htmlCode);

// Prepare SQL statement with parameterized query
$stmt = $pdo->prepare("INSERT INTO table_name (html_code) VALUES (:htmlCode)");
$stmt->bindParam(':htmlCode', $htmlCode);
$stmt->execute();