Reputation: 899
I am trying to get comments from users but the browser says Fatal error: Function name must be a string. My code;
// <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";
?>
Upvotes: 2
Views: 11123
Reputation: 7693
Probably
$_POST['comment']
instead of ('comment'). Btw: make sure you escape this, unless you don't care about SQL injection / XSS attack
Upvotes: 1
Reputation: 49386
Array dereferences are performed with brackets: [
and ]
. So....
$comment = $_POST['comment'];
Upvotes: 9
Reputation: 33789
You used parentheses after $_POST
when you wanted square brackets.
Upvotes: 2