我知道了類似的問題已經回答了,但我的情況下,我沒有使用布爾我得到這個錯誤警告:mysql_num_rows()預計參數1是資源,在給定的空(不是布爾)
警告:mysql_num_rows()預計參數1是資源,在/home3/arm103/public_html/battle.php空給出第19行
這裏是從第1行至battle.php 25
<?php
session_start();
include("header.php");
if(!isset($_SESSION['uid'])){
echo "You must be logged in to view this page!";
}else{
if(isset($_POST['gold'])) {
$energy = protect($_POST['energy']);
$id = protect($_POST['id']);
$user_check = mysql_query("SELECT * FROM `stats` WHERE `id`='".$id."'") or die(mysql_error());
if(mysql_num_rows($user_check) ==0) {
output("There is no user with that ID!");
}elseif($energy < 1 || $energy > 10) {
output("You must attack with 1 - 10 energy!");
}elseif($energy > $stats['energy']){
output("You do not have enough energy!");
}elseif($id == $_SESSION['uid']) {
output("You can not attack yourself!");
}elseif(mysql_num_rows($attacks_check) > 9) {
output("This person has been already attacked the maximum of 10 times in the last 24 hours!");
}else{
$enemy_stats = mysql_fetch_assoc($user_check);
$attack_effect = $energy * 0.1 * $stats['attack'];
$defence_effect = $enemy_stats['defence'];
這將是偉大的,如果有人能告訴我的問題,謝謝
可能重複的[mysql \ _fetch \ _array()期望參數1是資源,布爾給出在選擇](http://stackoverflow.com/questions/2973202/mysql-fetch -array-expect-parameter-1-to-resource-boolean-given-in-select) –
'$ attacks_check'從哪裏來? :) –