0

I have an if/else statement inside of an elseif statement that is causing the following issue "syntax error, unexpected '{'". Here is the code causing the problem:

$calendar = json_decode($calendarapi);
  if(isset($calendar->id) && $calendar->status != 'cancelled'){
    $returnvalues['id'] = $calendar->id;
    $returnvalues['success'] = true;
      return $returnvalues;
  }
  elseif($calendar->status == 'cancelled'){
    $calendarapi = $this->GoogleCalendarAdd($request, $request, $calendarDescription, $startDateTime, $endDateTime);
    $calendar = json_decode($calendarapi);
  if(isset($calendar->id){               //Error Happens here
      $basic['OldSchedule']->calendar_id = $calendar->id;
      $basic['OldSchedule']->save();
      $returnvalues['success'] = true;
      return $returnvalues;
    }else{
    $returnvalues['success'] = false;
    return $returnvalues;
  }
}

I have looked over it a couple dozen times, but I can't figure out where I went wrong. All semicolons are where they are supposed to be. My code editor, Atom, shows that the if/else statement are nested inside the elseif statement, so I am out of things that could be causing the error.

Eric Brown
  • 1,312
  • 3
  • 15
  • 30
  • 1
    You are missing a `)` in this line: `if(isset($calendar->id){` That means the parser sees the `{` too early, i.e., before it sees the closing `)`. Your code should be (with decent formatting): `if(isset($calendar->id)) {` – elixenide May 30 '17 at 02:39
  • Yup, that did it. Thank you. – Eric Brown May 30 '17 at 02:41

1 Answers1

0
 elseif($calendar->status == 'cancelled'){
    $calendarapi = $this->GoogleCalendarAdd($request, $request, 
$calendarDescription, $startDateTime, $endDateTime);
    $calendar = json_decode($calendarapi);

You are missing a } at the end there