意外{预期(?

时间:2010-05-01 10:30:03

标签: php

解析错误:语法错误,意外'{',期待'('在第313行的/home/a7237281/public_html/include/session.php

这是我得到的错误,与此代码有关

      //check the emails
  $field = "email";  //Use field name for email
  $field2 = "email2";
  if(!$subemail || strlen($subemail = trim($subemail)) == 0)
  {
     $form->setError($field, "* Email not entered");
  }
  else if
  {
     /* Check if valid email address */
     $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
             ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
             ."\.([a-z]{2,}){1}$";
     if(!eregi($regex,$subemail))
     {
        $form->setError($field, "* Email invalid");
     }
     else if ($subemail !== $subemail2)
     {
        $form->setError($field2, "* Emails does not match");
     }
     $subemail = stripslashes($subemail);
  }
  /* Check if email is already in use */
  else($database->emailTaken($subemail))
  {
    $form->setError($field, "* Email address already in use");
  }

它指的是{在第一个之后如果。

我已经编辑了整段代码,我现在该怎么办?

2 个答案:

答案 0 :(得分:6)

当然是。你忘记了条件。您确定您的意思是else if而不只是else吗?

答案 1 :(得分:2)

为if

添加条件
else if(something ?!)

或删除if if read read

else