0

I've got error on defined-function and from error_reporting(E_ALL);

There are errors Parse error: syntax error, unexpected ',', expecting variable (T_VARIABLE) in C:\xampp\htdocs\bs4\func.php on line 4

Here is my code

<?php
error_reporting(E_ALL);
require_once "condb.php";
function noproblem(time,suggest,phone,eat,problem){ // Here is line 4

  $sql="insert into data(time,suggest,phone,eat,problem) values(?,?,?,?,?)";
  $stmt=$cn->prepare($sql);
  $stmt->bindParam("1",time);
  $stmt->bindParam("2",suggest);
  $stmt->bindParam("3",phone);
  $stmt->bindParam("4",eat);
  $stmt->bindParam("5",problem);

  try {
    $stmt->execute();
    echo "ok!";
  } catch (Exception $e) {
    echo $e->getTraceAsString();
  }
}
?>

3 Answers 3

14

In PHP variables have to start with a $:

function noproblem($time,$suggest,$phone,$eat,$problem){

The same applies to all other variables in the example.

Sign up to request clarification or add additional context in comments.

Comments

1

Variables starts with "$" sign.

Comments

1

If you are certain that all variables starts with "$" sign, your PHP version might be the cause.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.