2011-06-22 78 views
-1

如果我錯了,更正我的錯誤,但我認爲mysql_real_escape_string應該把轉義字符放在像(')和(「)這樣的字符前面,我正在使用的簡單設置如下。我期待看到在phpMyAdmin看,但轉義字符不存在上述字符之前反斜槓創造了新的紀錄。mysql_real_escape_string沒有放置轉義字符

$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); 
?> 
+0

因爲它是未轉義的 – Ibu

回答

2

與mysql_real_escape_string這些轉義字符不被存入數據庫

+0

我沒有看到它們在警報提示中。我在警報提示中看到它們? –

+2

@JohnR:反斜線也是javascript中的轉義字符:)所以,不,你不會在警報中看到它們。嘗試查看源代碼,你應該看到它們。 –

+0

@Wesley Murch,我在源代碼中看到他們,感謝您的提示。 –