【问题标题】:Unexpected { expected (? [closed]意外{预期(?[关闭]
【发布时间】:2011-02-14 12:40:35
【问题描述】:

解析错误:语法错误,意外的 '{',在第 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");
  }

它指的是第一个 else if 之后的 {。

我已经编辑了整段代码,我现在可以做什么?

【问题讨论】:

标签: php


【解决方案1】:

当然是。你忘了给出条件。你确定你指的是else if 而不仅仅是else

【讨论】:

  • 然后呢?你还没有条件。
  • @Luke:所以? ;-) 如果是无条件语句,则使用else 而不是else if
  • else($database->emailTaken($subemail))hehehe
【解决方案2】:

要么为 if 设置条件

else if(something ?!)

或删除 if 这样它会读取

else

【讨论】:

    猜你喜欢
    • 2019-05-24
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-25
    • 2018-09-20
    • 1970-01-01
    相关资源
    最近更新 更多