Because in the second example you have two commands, so when it gets to the else it has lost track with the if.
This is ok: if (something) do this; This is ok: if (something) do this; else do that; This is how you nest more than one command: if (something) { do this; then do this; } else { do something else; and then make some tea; } The multiple commands are nested inside {} brackets. Jeremy Burns Class Outfit http://www.classoutfit.com On 8 Nov 2011, at 12:08, shmeg wrote: > Can anyone tell my why this works: > > > <?php > if($facebook_user) > echo $this->Facebook->logout(); > else > echo $this->Facebook->login(); > ?> > <p> > <?php echo debug($facebook_user); ?> > > but this produces the an error (Parse error: syntax error, unexpected > T_ELSE in /home/worldtri/public_html/testapp/views/pages/home.ctp on > line 8) > > > <p> > <?php > if($facebook_user) > echo $this->Facebook->logout(); > echo debug($facebook_user); > else > echo $this->Facebook->login(); > ?> > > <p> > > With thanks for any and all explanations. > Benjamin. > > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php