我在创建的模拟网站上收到此错误。不确定这里的实际问题是什么。任何帮助将不胜感激。谢谢!
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home4/user/public_html/index.php on line 6
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/user/public_html/index.php on line 8
的index.php
<?php
include_once("php_includes/check_login_status.php");
$sql = "SELECT username FROM users WHERE activated = '1' ";
$query = mysqli_query($db_conx, $sql );
$usernumrows = mysql_num_rows($query);
$userlist = "";
while($row = mysql_fetch_array($query, MYSQLI_ASSOC)) {
$u = $row["username"];
$userlist .='<a href = "user.php?u='.$u.'">'.$u.'</a> | ';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RM</title>
<link rel="stylesheet" href="style/style.css">
<script src="js/main.js"></script>
</head>
<body>
<?php include_once("template_pageTop.php"); ?>
<div id="pageMiddle"> </div>
<?php include_once("template_pageBottom.php"); ?>
</body>
</html>
答案 0 :(得分:2)
您正在混合mysqli_*
和mysql_*
个功能;这是行不通的。
答案 1 :(得分:1)
如前所述,混合mysqli_*
和mysql_*
功能将无效。
此外,mysql_num_rows
期望资源作为参数而不是SQL查询字符串。正如PHP manual