-2

my php file:

    if($operation=='upload'){
    if(isset($data -> paper) && !empty($data -> paper) && isset($data -> paper -> author) && isset($data -> paper -> description) && isset($data -> paper -> title)){

      $author = $data -> paper -> author;
      $description= $data -> paper -> description;
      $title = $data -> paper -> title;

      echo $fun -> uploadPaper($author,$description,$title);
    }

json

  {
   "operation": "upload",
   "paper": {
    "author": "Mark Watson",
    "description": "The book writing about AI by Mark Waton",
    "title": "Practical Artificial Intelligence Programming With Java"
}
}

when i send json to server by post method,there is a error:

Parse error: syntax error, unexpected '$author' (T_VARIABLE) in D:\xampp\htdocs\server\index.php on line 78

i really don't know what is happening!please tell me

user4330975
  • 21
  • 1
  • 3

1 Answers1

0

Something is wrong/odd with your opening brace in your second if statement. This is the fixed version:

if ($operation == 'upload') {

    if(isset($data -> paper) && !empty($data -> paper) && isset($data -> paper -> author) && isset($data -> paper -> description) && isset($data -> paper -> title)) {

        $author = $data->paper->author;
        $description = $data->paper->description;
        $title = $data->paper->title;

        echo $fun->uploadPaper($author, $description, $title);

    }

}
Yolo
  • 1,569
  • 1
  • 11
  • 16