gpt4 book ai didi

php - 函数缺少参数警告

转载 作者:行者123 更新时间:2023-11-30 23:15:41 25 4
gpt4 key购买 nike

我已经构建了一个函数来专门处理我的登录系统的一部分。

这是我被击落的错误:

Warning: Missing argument 2 for dbclass::logcon(), called in C:\xampp\htdocs\1\login.php on line 105 and defined in C:\xampp\htdocs\1\assets\includes\functions.php on line 10

这是有问题的代码

if (isset($_POST['submit'])) {

$user = $_POST['user'];
$password = $_POST['password'];

//To ensure that none of the fields are blank when submitting the form if
if (isset($_POST['user']) && isset($_POST['password'])) {

$user = stripslashes($user);
$password = stripslashes($password);

$db1 = new dbclass();
$db1->openDB();
$sql = "SELECT * FROM users WHERE username='{$user}' AND password='{$password}'";


$result = $db1->logcon($sql);
$row = mysqli_fetch_array($result);

最后是我的函数。

function logcon($user, $password) {

$esc_user = mysqli_real_escape_string($this->conn, $user);
$esc_password = mysqli_real_escape_string($this->conn, $password);
$sql = "select * all from users where username ='{$user}' AND password='{$password}";
$result = mysqli_query($this->conn, $sql);

if ($result) {
$numofrows = mysqli_affected_rows($this->conn);
return $numofrows;
} else
$this->error_msg = "could not connect!";
return false;

}

如您所见,我已经传递了 2 个参数。因此,无可否认,困惑得到控制。

最佳答案

你得到了:

function logcon($user, $password )

但是

$result=$db1->logcon($sql);

关于php - 函数缺少参数警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17982058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com