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";
?>
You used parentheses after $_POST
when you wanted square brackets.
Array dereferences are performed with brackets: [
and ]
. So....
$comment = $_POST['comment'];
$_POST['comment'];
Square brackets instead of parenthesis.
Probably
$_POST['comment']
instead of ('comment'). Btw: make sure you escape this, unless you don't care about SQL injection / XSS attack
Use $_POST['comment'] instead of $_POST('comment');