本文介绍了警告:mysql_num_rows()期望参数1是资源,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个错误,它说
警告:mysql_num_rows()期望参数1是资源,布尔值在C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\ / pre>
这里是代码
我尝试了什么:
<?php session_start();
require(header.php);
require(checkUser.php);
$ id = $ _ GET [id];
$ page = $ _GET ['page'];
$ var = $ page * 4-4;
?>
< style>
。分页a {
颜色:黑色;
float:center;
填充:8px 16px;
text-decoration:none;
过渡:background-color .3s;
}
.pagination a.active {
background-color:black;
颜色:白色;
}
。分页a:悬停:不是(.active){background-color:#ddd;}
< / style>
< a class =btnShref =question.php?stid =<?php echo $ id?>>提问< / a>
< hr />
<?php
$ str =SELECT * FROM question,user WHERE question.user_id = user.user_id and subtopic_id = $ id Limit $ var,4;
$ result = ExecuteQuery($ str);
$ no_rows = mysql_num_rows($ result);
if($ no_rows> 0)
{
while($ row = mysql_fetch_array($ result))
{
$ rowsc = ExecuteQuery( SELECT count(*)作为来自answer_id = $ row [question_id]的答案的计数器;);
$ rowc = mysql_fetch_array($ rowsc);
$ count = $ rowc ['counter'];
echo< h4>;
echo< span class ='box2'>;
echo< span class ='head'>< a href ='questionview.php?qid = $ row [question_id]'> $ row [heading]< / a>< / span> ;;
echo< / span>;
echo< / h4>;
echo$ row [question_detail]< span class ='view2'>观看次数:$ row [views],回复:$ count< / span>;
echo< br />< br />;
echo< br /> $ row [fullname]提问;
echo< br />< div class ='line'>< / div>;
}
}
其他
{
echo目前没有问题;
}
?>
< br>< br>
< center> < div class =pagination>
< a href =>«< / a>
<?php
for($ i = 1; $ i< = 10; $ i ++){
echo'< a class =activehref =questions.php ?页=> $我。 ';'。$岛 '< / A>';
}
?>
< a href =#>»< / a>
< / div>< / center>
< br>
<?php require(footer.php)?>解决方案
i have an errors it says
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\amargaforum\questions.php on line 39
here's the code
What I have tried:<?php session_start(); require("header.php"); require("checkUser.php"); $id=$_GET["id"]; $page = $_GET['page']; $var=$page*4-4; ?> <style> .pagination a { color: black; float: center; padding: 8px 16px; text-decoration: none; transition: background-color .3s; } .pagination a.active { background-color: black; color: white; } .pagination a:hover:not(.active) {background-color: #ddd;} </style> <a class="btnS" href="question.php?stid=<?php echo $id ?>">Ask Question</a> <hr /> <?php $str="SELECT * FROM question, user WHERE question.user_id=user.user_id and subtopic_id=$id Limit $var,4"; $result=ExecuteQuery($str); $no_rows = mysql_num_rows($result); if ($no_rows > 0) { while($row = mysql_fetch_array($result)) { $rowsc=ExecuteQuery("SELECT count(*) as counter from answer where question_id=$row[question_id]"); $rowc = mysql_fetch_array($rowsc); $count = $rowc['counter']; echo "<h4>"; echo "<span class='box2'>"; echo "<span class='head'><a href='questionview.php?qid=$row[question_id]' >$row[heading]</a> </span>"; echo "</span>"; echo "</h4>"; echo "$row[question_detail] <span class='view2'>Views : $row[views], Replies :$count</span>"; echo "<br/><br/>"; echo "Asked by<br/>$row[fullname]"; echo "<br/><div class='line'></div>"; } } else { echo "No questions at the moment"; } ?> <br><br> <center> <div class="pagination"> <a href="">«</a> <?php for ($i=1; $i <= 10; $i++) { echo '<a class="active" href="questions.php?page='.$i.'">'.$i.'</a>'; } ?> <a href="#">»</a> </div></center> <br> <?php require("footer.php")?>解决方案
这篇关于警告:mysql_num_rows()期望参数1是资源,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!