I Get a Syntax Error: Expected:

I am using netbeans IDE and have some php
I include a file, create an object based on the include file session.class
I test a session variable, curly bracket
place a comment close the curly bracket and this second curly bracket is highlighted and I get a syntax error expected a whole list of items that could be right
I do not understand why this is happening

Can anybody please explain why this happens

attached is the code I have the problem with

and a screen print of netbeans

 netbeanserror.docx
<?php
require_once("./include/Session.class");
$sess = new Session();
$test = $sess->getVariable("auth");
if ( $test == "yes" );
{
    // seesion authorised = yes
}
else
{
    file_put_contents("filename.txt",$sess->getVariable('auth'), FILE_APPEND);
    header("Location: index.php");
    exit();
}
/*
 *  Program:  UMCSITE1.php
  * Desc:     Create user managed codes that manage dropdown lists
  *
  *
  */
require_once("./include/WebForm.class");
require_once("./include/Account.class");
require_once("./include/Database.class");
require_once("./include/Email.class");
require_once("./include/umcs.class");


try
{
  $form =
    new WebForm("umcsform.inc","umcsflds.inc",$_POST);
}
catch(Exception $e)
{
  echo $e->getMessage();
  exit();
}
//First time form is displayed. Form is blank. //
if (!isset($_POST['Button']))
{
   $form->displayForm();
   exit();
}
// Process form that has been submitted with user info  //
else
{
  try
  {
     $db = new Database("./include/Vars.inc");
     $db->useDatabase("r3prototype");
     $acct = new Account($db->getConnection(),"umcs");
  }
  catch(Exception $e)
  {
     echo $e->getMessage()."\n<br>";
     exit();
  }

  // Save and add in form was submitted  //
  if ($_POST['Button'] == "Save")
  {
     $not_required[] = "euser_cr_NID";
     $not_required[] = "euser_am_NID";
     $not_required[] = "amend_date";
     $not_required[] = "create_date";
     try
     {
         $form->setFieldsNotRequired($not_required);
         $blanks = $form->checkForBlanks();
     }
     catch(Exception $e)
     {
         echo $e->getMessage();
     }
     if(is_array($blanks))
     {
        $GLOBALS['message_2'] =
           "The following required fields were blank.
                Please enter the required information:  ";
        foreach($blanks as $value)
        {
           $GLOBALS['message_2'] .="$value, ";
        }
        $form->displayform();
        exit();
     }
     $form->trimData();
     $form->stripTagsFromData();
     try
     {
        $errors = $form->verifyData();
     }
     catch(Exception $e)
     {
        echo $e->getMessage();
     }
     if(is_array($errors))
     {
        $GLOBALS['message_2'] = "";
        foreach($errors as $value)
        {
           $GLOBALS['message_2'] .="$value<br> ";
        }
        $form->displayform();
        exit();
     }
     $newdata = $form->getAllFields();
     $newumcs = new umcs("./include/vars.inc");
     try
     {
      
       if(!$newumcs->createNewUmc($newdata, $sess->getVariable(user_name_logged)))
       {
         echo "Couldn't create new account.
                          Try again later.";
         exit();
       }

       }
     catch(Exception $e)
     {
       echo $e->getMessage();
       exit();
     }
     exit();
  }
  elseif($_POST['Button'] == "Cancel")
  {
     header("Location: index.php");
     exit();
  }
}

?>

Open in new window

johnecollinsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

speak2abCommented:
I run into this error whenever i have put a method inside another method by mistake. Check the order and number of all the braces { }

Secondly, be sure you specify the error you catch with the Try. See: http://java.syntaxerrors.info/index.php?title=Syntax_error_on_token_%22catch%22,_finally_expected

This should get you started, If you have not resolved it by the time i am back I will look closely through your codes.

Goodluck.
0
johnecollinsAuthor Commented:
speak2ab:

  cheers thanks for that I will look at those points and will and deliberate

thanks for your swift reply

john
0
Ray PaseurCommented:
Line 5:

if ( $test == "yes" );

Remove the semicolon.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

johnecollinsAuthor Commented:
Ray,

Once again you have sorted me out, please can you tell me where you bought your glasses - I must get a pair ;-) I have been looking at this all night I was pulling out so much hair I was in danger of becoming your avatar ;-)

I really must come  to the US and buy you a beer!

semi-colon deleted and everything is marvelous
0
johnecollinsAuthor Commented:
Cheers Ray

Thank you so much

John
0
johnecollinsAuthor Commented:
speak2ab:

thank you for your effort as well
0
Ray PaseurCommented:
Ha!  You cannot imagine how many times I have reflexively typed a semicolon at the end of a foreach() or a where().  When you've been making the same mistake for years it becomes really easy to identify it ;-)

Thanks for the points (and maybe one day we can get that beer), ~Ray
0
johnecollinsAuthor Commented:
Hi  Ray, I am looking forward to it ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.