PHP: 处理文件处理中的 ' 和 " SQL

PHP: Handle the ' and " in file handling and SQL

我有一个包含单引号 (') 和双引号 (") 的文件。数据库中有一个字段,我在其中保存文件的内容。

现在,问题出现在 SQL 查询中,因为 ' 和 " 相互冲突。在 SQL 查询中有 ' 引号,文件内容有自己的引号。所以,它们是冲突的. 我该如何处理?

这是我正在尝试执行的代码:

$filename = "folder/file.txt";
$file_content = file_get_contents($filename);
$sql = 'INSERT INTO table (content)
        VALUES ('.$file_content.')';
if ($conn->query($sql) === TRUE) {
    echo "value submitted";
}else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

请帮忙。

借助 mysql_real_escape_string 方法在插入前对字符串进行转义。