What are the potential security risks associated with parsing email content in PHP for database insertion?

When parsing email content in PHP for database insertion, one potential security risk is the injection of malicious code through the email content. To mitigate this risk, it is important to sanitize the email content before inserting it into the database. This can be done by using PHP's filter_var() function with the FILTER_SANITIZE_STRING filter to remove any potentially harmful characters.

// Sanitize email content before inserting into database
$email_content = filter_var($email_content, FILTER_SANITIZE_STRING);

// Insert sanitized email content into database
$query = "INSERT INTO emails (content) VALUES ('$email_content')";
mysqli_query($connection, $query);