gpt4 book ai didi

php - 计算行数时出错

转载 作者:行者123 更新时间:2023-11-29 06:15:05 25 4
gpt4 key购买 nike

我正在登录,但在计算 MySQL 查询的行数时出现错误。错误如下。

 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/nzcraftn/public_html/bs/login.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at /home/nzcraftn/public_html/bs/login.php:13) in /home/nzcraftn/public_html/bs/login.php on line 21

我正在使用此代码进行登录。

<?php
session_start();
include('config.php');

$user = protect($_POST['username']);
$pass = protect($_POST['password']);

$salt = "a123b123";
$thepass = md5($salt.md5($pass));

$res = mysql_query("SELECT `username`,`password` WHERE (`username` = '$user' AND `password` = '$thepass')");

$count = mysql_num_rows($res);

if($count == 1) {
$_SESSION['user'] = $user;
print($_SESSION['user']);
//header('Location: /panel/index.php');
} else {
$_SESSION['errormsg'] = "<div style='color: #FF0000'>Invalid Login!</div>";
header('Location: index.php');
}
?>

最佳答案

您的语句中有错误,因此 mysql_query 返回 false。请在您的代码中添加错误检查(以及用于调试的日志记录)。

(您的 SELECT 缺少 FROM 子句。)

关于php - 计算行数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7055579/

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