user893970
user893970

Reputation: 899

fatal error Function name must be a string

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

Answers (5)

Brad
Brad

Reputation: 5488

$_POST['comment'];

Square brackets instead of parenthesis.

Upvotes: 2

Manu R S
Manu R S

Reputation: 970

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

Upvotes: 0

mkk
mkk

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

Adam Wright
Adam Wright

Reputation: 49386

Array dereferences are performed with brackets: [ and ]. So....

$comment = $_POST['comment'];

Upvotes: 9

John Flatness
John Flatness

Reputation: 33789

You used parentheses after $_POST when you wanted square brackets.

Upvotes: 2

Related Questions