解析错误:语法错误,第39行/hermes/bosnaweb15a/b1372/ipg.thestephaniestorecom/mysql.php中的意外“{”

时间:2017-11-09 18:27:31

标签: php mysql

需要php帮助。在尝试连接到mysql数据库时收到错误消息..下面是我的抱怨的第39行的源代码:

    // checks username does not exist
    public function checkUsername($username) {
         $sql = "SELECT username FROM Registration WHERE username = '$username'";
         $this->result = mysqli_query($this->conn, $sql);
         if (mysqli_num_rows($this->result <= 0) {
              return false;
         }     
         return true;

1 个答案:

答案 0 :(得分:0)

您缺少文件末尾的括号,这会关闭该功能。你在这里也遗漏了一个:if (mysqli_num_rows($this->result <= 0) {

将您的代码更改为:

public function checkUsername($username) {
         $sql = "SELECT username FROM Registration WHERE username = '$username'";
         $this->result = mysqli_query($this->conn, $sql);
         if (mysqli_num_rows($this->result ) <= 0 ) {
              return false;
         }     
         return true;

}

下次使用这样的语法检查器:https://phpcodechecker.com/