如果我错了,请纠正我,但我认为 mysql_real_escape_string 应该在 (') 和 (") 等字符前面放置转义字符。我正在使用的简单设置如下。我期待看到创建的新记录在 phpMyAdmin 中查看时,在上述字符之前带有反斜杠,但转义字符不存在。
$text = mysql_real_escape_string($_POST['text']);
$detailedText = mysql_real_escape_string($_POST['detailedText']);
$type = mysql_real_escape_string($_POST['type']);
$image = mysql_real_escape_string($_POST['image']);
?>
<script> alert("<?php echo $text ?>");</script>
<?php
$result = mysql_query(
"INSERT INTO nodes (text, detailedText, type, image)
VALUES ('". $text . "','" . $detailedText . "','" . $type . "','" . $image . "')");
mysql_close($conn);
?>