警告:mysql_fetch_array():提供的参数不是有效的 MySQL 结果资源

发布于 2024-11-27 12:43:03 字数 1407 浏览 0 评论 0原文

可能的重复:
警告:mysql_fetch_array():提供的参数不是有效的 MySQL 结果

这是我遇到问题的脚本部分。以下所有查询均有效,并且结果在页面上正确显示,除了$sType=“评级”。这会导致警告出现在数据的位置。我尝试在服务器上运行特定查询并且它正确返回。当我在网页上使用它时,它只会给我一个错误。有谁知道问题可能是什么?

$sType=$_GET["sort"];
$newQuery;
    if($sType=="lowHigh")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY SalePrice");
    }
    else if($sType=="highLow")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY SalePrice DESC");  
    }
    else if($sTpye=="rating")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY Rating DESC, NumRatings DESC") or die(mysql_error());

    }
    else if($sType=="mostReviews")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY NumRatings DESC");     
    }
        $p1=mysql_fetch_array($newQuery);
        $p2=mysql_fetch_array($newQuery);
        $p3=mysql_fetch_array($newQuery);
        $p4=mysql_fetch_array($newQuery);
        $p5=mysql_fetch_array($newQuery);
        $p6=mysql_fetch_array($newQuery);
        $p7=mysql_fetch_array($newQuery);
        $p8=mysql_fetch_array($newQuery);

Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

This is the part of my script that I'm having issues with. All of the following queries work and the results display properly on the page except for $sType="rating". This the one that causes the warning to appear in place of the data. I've tried running the specific query on the server and it returns properly. It only gives me an error when I use it on the webpage. Does anyone have any idea what the issue might be?

$sType=$_GET["sort"];
$newQuery;
    if($sType=="lowHigh")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY SalePrice");
    }
    else if($sType=="highLow")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY SalePrice DESC");  
    }
    else if($sTpye=="rating")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY Rating DESC, NumRatings DESC") or die(mysql_error());

    }
    else if($sType=="mostReviews")
    {
        $newQuery = mysql_query("SELECT * FROM Products ORDER BY NumRatings DESC");     
    }
        $p1=mysql_fetch_array($newQuery);
        $p2=mysql_fetch_array($newQuery);
        $p3=mysql_fetch_array($newQuery);
        $p4=mysql_fetch_array($newQuery);
        $p5=mysql_fetch_array($newQuery);
        $p6=mysql_fetch_array($newQuery);
        $p7=mysql_fetch_array($newQuery);
        $p8=mysql_fetch_array($newQuery);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流绪微梦 2024-12-04 12:43:03

您在“评级”支票中输入了错误的 $sType

You've mistyped $sType in your check for "rating".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文