2011-08-15 113 views
0

我想从用户那里得到评论,但浏览器说致命错误:函数名称必须是字符串。我的代码;致命错误函数名称必须是字符串

// <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"; 

?> 

回答

1

当你想要方括号时,你在$_POST之后使用了圆括号。

10

使用括号进行数组解引用:[]。所以....

$comment = $_POST['comment']; 
1
$_POST['comment']; 

方括号,而不是括号。

1

大概

$_POST['comment'] 

,而不是( '评论')。顺便说一句:除非你不在乎SQL注入/ XSS攻击

+0

而不是$ comment = $ _POST ['comment']我会写$ comment = mysql_real_escape_string($ _ POST ['评论'])。然后当你显示它时,确保你可以把它包装在htmlentities()方法中。可能这是不够的,但总比没有好 – mkk

0

Use $_POST['comment'] instead of $_POST('comment');

Use $_POST['comment'] instead of $_POST('comment');

相关问题