我想從用戶那裏得到評論,但瀏覽器說致命錯誤:函數名稱必須是字符串。我的代碼;致命錯誤函數名稱必須是字符串
// <form name="form1" method="post" action="posting.php">
// <input name="comment" type="text" id="comment" style="width:254px; height:44px;">
// </form>
<?php
$comment = $_POST('comment');//this was the line where problem occured
if(!empty($comment))
{
mysql_query("INSERT INTO comment (comment) VALUES('".$comment."')");
}
echo "$comment";
?>
而不是$ comment = $ _POST ['comment']我會寫$ comment = mysql_real_escape_string($ _ POST ['評論'])。然後當你顯示它時,確保你可以把它包裝在htmlentities()方法中。可能這是不夠的,但總比沒有好 – mkk