0

在我创建的模拟网站上出现此错误。不确定这里的实际问题是什么。任何帮助将不胜感激。谢谢!

错误:

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


索引.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> &nbsp; | &nbsp;';
    }
?>


<!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">&nbsp;</div>
        <?php include_once("template_pageBottom.php"); ?>
    </body>
</html>
4

2 回答 2

2

您正在混合mysqli_*mysql_*功能;那是行不通的。

于 2013-09-21T20:24:49.617 回答
1

如前所述,混合mysqli_*mysql_*功能将不起作用。

此外,mysql_num_rows期望资源作为参数而不是 SQL 查询字符串。如PHP 手册中所述

于 2013-09-21T20:33:43.983 回答