我知道了类似的问题已经回答了,但我的情况下,我没有使用布尔我得到这个错误警告: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'从哪里来? :) –