我收到提到的错误。我在 conn.php 中有数据库连接,我包含在 fn.php 中。但是,在特定的行上它给出了错误
注意:未定义的变量:第 16 行 fn.php 中的 rezistent
第 16 行是:
$a = mysqli_query($rezistent, "SELECT is_verified FROM users WHERE veri_key = '$key'") or die(mysqli_error());
这是我的 conn.php
<?php
$user = "mmoin";
$pass = "pass";
$host = "localhost";
$dbname = "rezistent";
$rezistent = mysqli_connect($host, $user, $pass, $dbname) or die("cannot connect with database");
?>
这是 fn.php
<?php
include "conn.php";
function hashit($v){
$hash = md5($v);
$hash .= rand(11,99);
return $hash;
}
function user_verification($k){
$account_type = substr($k, 0, 1);
$key = substr($k, 1);
$msg_to_display = "";
if($account_type == "h" || $account_type == "t"){
$a = mysqli_query($rezistent, "SELECT is_verified FROM users WHERE veri_key = '$key'") or die(mysqli_error());
$rows = mysqli_num_rows($a);
if($rows > 0){
mysqli_query($rezistent, "UPDATE users SET is_verified = '1' WHERE veri_key='$key'");
$msg_to_display = "User successfully verified. Please use the login link to login with your credentials.";
}
}
else{
$msg_to_display = "There seems to be a problem with the verification key. Please try again from the link provided in the email.";
}
return $msg_to_display;
}
?>
可能是什么问题?我什至尝试在函数之前立即连接数据库,但它仍然给出相同的通知消息。