我收到此错误,为什么它期望参数不是布尔值?我该如何解决?(我知道这是一个常见的错误,所以我想了解它为什么会出现,这样当它再次出现时我可以自己修复它。)
警告:mysqli_stmt_num_rows() 期望参数 1 为 mysqli_stmt,布尔值在 C:\Users\James\Desktop\Container\XAMPP\htdocs\Triiline1\signupuser.php 第 20 行给出
<!doctype html>
<html>
<head>
<title>User Signup</title>
</head>
<body>
<?php
include 'connect.php';
//if submit is clicked
if (isset($_POST['submit'])) {
//then check if all fields are filled
if (empty($_POST['username']) | empty($_POST['password']) | empty($_POST['firstname']) | empty($_POST['MI']) | empty($_POST['lastname']) | empty($_POST['email']) | empty($_POST['phonenumber']) | empty($_POST['country']) ) {
echo('You did not complete all of the required fields'); }
$username = $_POST['username'];
$password = $_POST['password'];
$usernamesquery = mysql_query("SELECT * FROM logins WHERE username='$username'");
if(mysqli_stmt_num_rows($usernamesquery) > 0) {
die('This username is already taken.');
}
} ?>
<form action="" method="post">
Username: <input type="text" name="username" maxlength="30"><br>
Password: <input type="password" name="password" maxlength="30"><br>
First Name: <input type="text" name="firstname" maxlength="30"><br>
Middle Initial: <input type="password" name="MI" maxlength="30"><br>
Last Name: <input type="text" name="lastname" maxlength="30"><br>
Email: <input type="password" name="email" maxlength="50"><br>
Phone Number: <input type="text" name="phonenumber" maxlength="11"><br>
Country: <input type="password" name="country" maxlength="40"><br>
<input type="submit" name="submit">
</form>
</body>
</html>