需要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;
答案 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/