gpt4 book ai didi

php - 给出警告 : mysql_real_escape_string() expects parameter 2 to be resource, 为空

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

<分区>

这是我的代码

当我尝试运行编码时出现 2 个错误

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/a5008269/public_html/Login.php on line 9

PHP 错误信息

Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/a5008269/public_html/Login.php on line 10

出于某种原因,我在第 9 行和第 10 行收到 2 个警告

请帮帮我

<?php
require_once('connector.php');
$error_msg = "";
if (!isset($_COOKIE['user_id'])) {
if (!isset($_POST['submit'])) {
$pass = hash('whirlpool', $_POST['password']);
$user_username = mysql_real_escape_string(CONNECT, $_POST['username']);
$user_pass = mysql_real_escape_string(CONNECT, $_POST['password']);

if (!empty($user_username) && !empty($user_pass)) {
$pass = hash('whirlpool', $user_pass);
$query = "SELECT * FROM playerinfo WHERE user = '$user_username' AND password = '$pass'";

$result = mysqli_query(CONNECT, $query);

if (mysqli_num_row == 1) {
$row = mysqli_fetch_array($result);
setcookie('user_id', 1);
setcookie('username', $row['name']);
setcookie('level', $row['adminlvl']);
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php';
header('Location: ' . $url);
} else {
$error_msg = 'Invalid Creditals';
}
} else {
$error_msg = 'Username Or Password field is left Empty';
}
}
}
?>
<html>
<head>
<title> Limitless Gaming ACP Login </title>
</head>
<body>
<h3> Log In </h3>
<?php
if (empty($_COOKIE['user_id'])) {
echo ' error logging in ';
?>
<form method = "post" action = "<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend> Log In </legend>
<label for="username"> username </label>
<input type="text" id="username" name="username"
value="<?php if (!empty($user_username)) echo $user_username; ?>" /><br />
<label for="password"> password </label>
<input type="password" id="password" name="password" />
</fieldset>
<input type="submit" value="log in" name="submit" />
</form>
<?php
}
else {
echo ('<p class="login"> You Are Logged in as ' . $_COOKIE['username'] . '.</p>');
}
?>

</body>
</html>

25 4 0