我正在尝试使用 PHPMyAdmin 创建一个登录系统,但我似乎遇到了绑定函数的问题。它应该打印存储在我登录帐户的数据库中的记录,但我从 uwamp 收到此错误;警告:mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in Prepared statement in C:\UwAmp\www\Test\M2\Authentication.php on line 22 供参考,这是我的代码;
<?php
//Perameters needed to login to the database
$serverName= "localhost";
$DBUsername= "root";
$DBPassword= "root";
$DatabaseName="database 1";
//Connect to the database using the parameters
$conn = new mysqli($serverName, $DBUsername, $DBPassword, $DatabaseName);
//If there is a connection error, kill the connection and show said error.
if ($conn -> connect_error)
{
die("Connection fail: " . $conn -> connect_error);
}
//Query the table
$paramUsername = $_POST['InputUsername'];
$paramPassword = $_POST['InputPassword'];
$Statement= $conn-> prepare("SELECT UserID, Name, Username, Password, PrivilegeLevel FROM users WHERE Username AND Password= ?");
$Statement -> bind_param('ss', $paramUsername, $paramPassword);
$Statement -> execute();
$Statement -> store_result();
$Statement -> bind_result($UserId, $UtBLName, $UtBLUsername, $UtBLPassword, $PrivLevel);
$Statement -> fetch();
$Statement -> close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<div>
Your user ID is: <?php echo $UserId; ?> <br>
Your name is: <?php echo $UtBLName; ?> <br>
Your username is: <?php echo $UtBLUsername; ?> <br>
Your password is: <?php echo $UtBLPassword; ?> <br>
Your privilege level is: <?php echo $PrivLevel; ?> <br>
</div>
</body>
</html>
现在我在这个网站上环顾四周,发现一个线程说我应该更改绑定 bind_param 中的 S-es 的数量,所以我将它从 1 更改为 2,但它仍然给出相同的错误。有什么建议么?