0

Here is my code and I don't know how to fix it, please help thanks! here is the par where the error is, it's on the line with $value.

    $db_selected = mysqli_select_db($link, DB_NAME);

    if (!$db_selected) {
    die('Can\'t use '. DB_NAME . ': ' .mysqli_error());
      } 

    $value = $_POST ('Name');
    $value2 = $_POST ('Email');
    $query= "INSERT INTO person (Name, Email) VALUES ('$value',      '$value2' )";

    if (!mysqli_query($query)) {
    die('Error: ' . mysql_error());
     }
sl8r34
  • 1
  • 1

2 Answers2

3

You've got a syntax error on these lines:

$value = $_POST ('Name');
$value2 = $_POST ('Email');

$_POST is an array, so you need to use square brackets to access it, like so:

$value = $_POST['Name'];
$value2 = $_POST['Email'];

Using regular brackets tells PHP that you're trying to call a function with the value in the variable $_POST. Because it's an array, it's throwing an error.

I should also add that you've got a serious SQL injection vulnerability. See this answer for more details: How can I prevent SQL injection in PHP?

iainn
  • 16,826
  • 9
  • 33
  • 40
1

I think you mean:

$value = $_POST['Name'];
$value2 = $_POST['Email'];

Notice the square brackets for $_POST instead of the parentheses you had.

Niklesh Raut
  • 34,013
  • 16
  • 75
  • 109
davidethell
  • 11,708
  • 6
  • 43
  • 63