中給出請有人可以告訴我這段代碼有什麼問題,它顯示此錯誤---------> 警告:mysql_num_rows()期望參數1在第62行上的/home/ocwnewco/public_html/user/rejectedcase.php中給出了布爾值,第62行顯示了這個-------> $ ocwConnections = mysql_num_rows($ result);數據庫mysql_num_rows()期望參數1是資源,布爾在
rejectedcase.php
<?php
require_once(ROOT_PATH.'DBconnect.php');
?>
<?php
/**
*get count of Reject
*
**/
function totalReject($zone,$Reject) {
$result = mysql_query("SELECT * FROM ocwconnections WHERE ZoneID = '$zone' AND RejectID = '$Reject'");
$ocwConnections = mysql_num_rows($result);
return $ocwConnections;
}
$ocwConnections = mysql_fetch_array(mysql_query("SELECT * FROM ocwconnections"));
$resultZone = mysql_query("SELECT * FROM `connection_zone` WHERE `Zone` <> 'All' ");
$resultReject = mysql_query("SELECT * FROM `connection_Reject` WHERE `Reject` <> 'All'");
?>
<?php
?>
<table border="1">
<tr>
<th class="tbhed">Zone</th>
<?php
$Reject = array();
while($connectioReject = mysql_fetch_array($resultReject)) {
echo "<th class=tbhed>".$connectioReject['Reject']."</th>";
$Reject[] = $connectioReject['RejectID'];
}
?>
<th class="tbhed">Total</th>
<th class="tbhed">Percentage</th>
</tr>
<?php
$arr = array();
while($connectioZone = mysql_fetch_array($resultZone)) {
?>
<tr>
<th><?php echo $connectioZone['Zone']; ?></th>
<?php
foreach($Reject as $value){
$arr[$connectioZone['ZoneID']][$value] = totalReject($connectioZone['ZoneID'],$value);
echo "<td>".totalReject($connectioZone['ZoneID'],$value)."</td>";
}
?>
<td><?php
$total = 0;
foreach($arr[$connectioZone['ZoneID']] as $value){
$total = $value + $total;
}
echo $total;
?>
</td>
<td><?php
foreach($arr[$connectioZone['ZoneID']] as $key => $val){
if($key == 2){
$complete = $val;
}
}
@$per = $complete * 100/$total;
if(!$per){
echo $per = 0;
}
else {
echo $per;
}
?>
% </td>
</tr>
<?php
}
?>
</table>
使用或從句前的mysql_query( 「查詢」)檢查您的查詢或死亡( 「查詢!」);這會讓你知道查詢是否正在執行。 – rohitr
請參閱[此答案](http://stackoverflow.com/a/11674313/250259)瞭解如何解決此問題。 –