解析错误:语法错误,意外的'||' (T_BOOLEAN_OR)在第6行的C:\ xampp \ htdocs \ cs \ Staff \ sign.php中

时间:2019-02-27 09:51:45

标签: php

我正在在线学习教程,但是每当尝试打开代码时,我都会不断收到此错误:

  

'解析错误:语法错误,意外的'||' (T_BOOLEAN_OR)   C:\ xampp \ htdocs \ cs \ Staff \ sign.php行6'。

我是PHP的新手(从3天前开始),所以我不知道该语句的含义。

如果有帮助,我的数据库称为“项目”,而我的表称为“ sign_up_a”。 我还有一行(我认为技术术语是一条记录),称为ID,这是主键,应该自动递增,因此在下面的代码中未包含它。这是正确的做法吗?

我的 sign.php 代码

<?php
  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $email = $_POST['email'];
  $password = $_POST['password'];
  if (!empty($firstname) || !empty($lastname)) || !empty($password) || !empty($email) {
     $host = "localhost";
     $dbUsername = "root";
     $dbPassword = "";
     $dbname = "project";
     //create connection
     $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
     if (mysqli_connect_error()) {
        die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
     } else {
        $SELECT = "SELECT email From sign_up_a Where email = ? Limit 1";
        $INSERT = "INSERT Into sign_up_a (firstname, lastname, email, password) values(?, ?, ?, ?)";
        //Prepare statement
        $stmt = $conn->prepare($SELECT);
        $stmt->bind_param("s", $email);
        $stmt->execute();
        $stmt->bind_result($email);
        $stmt->store_result();
        $rnum = $stmt->num_rows;
        if ($rnum==0) {
           $stmt->close();
           $stmt = $conn->prepare($INSERT);
           $stmt->bind_param("ssssii", $firstname, $lastname, $email, $password);
           $stmt->execute();
           echo "New record inserted sucessfully";
        } else {
           echo "Someone already register using this email";
        }
        $stmt->close();
        $conn->close();
  }
} else {
    echo "All field are required";
die();
}
?>

0 个答案:

没有答案