警告: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在“评级”支票中输入了错误的 $
sType
。You've mistyped $
sType
in your check for "rating".