簡體   English   中英

致命錯誤 Function 名稱必須是字符串

[英]fatal error Function name must be a string

我試圖從用戶那里獲得評論,但瀏覽器顯示致命錯誤:Function name must be a string。 我的代碼;

// <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'];

當您需要方括號時,您在$_POST之后使用了括號。

$_POST['comment'];

方括號代替圓括號。

大概

  $_POST['comment']

而不是(“評論”)。 順便說一句:確保你逃脫這個,除非你不關心 SQL 注入/XSS 攻擊

使用 $_POST['comment'] 而不是 $_POST('comment');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM