Jump to content
MakeWebGames

War View Error


Recommended Posts

Hello. I have this error which I can not fix!? I tried everything that I can...

 

function faction_warview()
{
global $db,$ir,$c,$userid,$factiondata;
$wq=mysql_query("SELECT * FROM factionwars WHERE warDECLARER={$ir['faction']} OR warDECLARED={$ir['faction']}");
print "<b>These are the wars your faction is in.</b><br />
		<hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th>Time Started</th><th>Versus</th><th>Who Declared</th><th>Available</th></tr>";
while($r=mysql_fetch_assoc($wq))
{
if($factiondata['factionID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; }
$d=date('F j, Y, g:i:s a',$r['warTIME']);
$ggq=mysql_query("SELECT * FROM factions WHERE factionID=".$r[$f]);
$them=mysql_fetch_assoc($ggq);
print "<tr><td>$d</td><td><a href='factions.php?action=view&ID={$them['factionID']}'><font color = red>{$them['factionNAME']}</font></a></td><td>$w</td> ";
	$cnt=mysql_query("SELECT * FROM users WHERE faction={$them['factionID']} AND hospital = 0 AND jail = 0");
print "<td><font color = green>".mysql_num_rows($cnt)."</font></td></tr>";
}
print "</table><hr width='100%'>";

$membcache.="<hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th colspan='11'>War Report For War Against: {$them['factionNAME']}</th></tr><tr><th>Nr.</th> <th>ID</th> <th>Name</th><th>Level</th><th>Money</th> <th>Location</th> <th>Ready To Be Attacked</th> <th>Hospital</th> <th>Reason</th> <th>Mail</th> <th>Attack</th></tr>";
$q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE faction=$f ORDER BY userid ASC");
$n=0;
while($r2=mysql_fetch_array($q))
{
if( $r2['hp'] >= 2 and (($r2['hospital'] == 0 and $ir['hospital']==0) || ($r2['hospital'] and $ir['hospital'])) and $r2['location'] == $ir['location']) { $color="green";$text="Yes"; } else
{ $color="red"; $text="No"; }
$n++;
if($r2['hospital']==0) { $r2['hospreason']=""; }
$membcache.="\n<tr><td>$n</td><td>{$r2['userid']}</td> <td><a href='viewuser.php?u={$r2['userid']}'>{$r2['username']}</a></td> <td>{$r2['level']}</td> <td>\${$r2['money']}</td> <td>{$r2['cityname']}</td> <td><span style='color:$color'>$text</span></td> <td>{$r2['hospital']} minute(s)</td> <td>{$r2['hospreason']}</td> <td>[<a href='mailbox.php?action=compose&ID={$r2['userid']}'>Send Mail</a>]</td> <td>[<a href='attack.php?ID={$r2['userid']}'>Attack</a>]</td></tr>";
}
$membcache.="</table><hr width='100%'><a href='yourfaction.php'>> Go Back</a><hr width='100%'>";



print $membcache;
}

 

error -

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/notl/public_html/yourfaction.php on line 1200

 

Line -

while($r2=mysql_fetch_array($q))
Link to comment
Share on other sites

Hello. I have this error which I can not fix!? I tried everything that I can...

 

function faction_warview()
{
global $db,$ir,$c,$userid,$factiondata;
$wq=mysql_query("SELECT * FROM factionwars WHERE warDECLARER={$ir['faction']} OR warDECLARED={$ir['faction']}");
print "<b>These are the wars your faction is in.</b><br />
		<hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th>Time Started</th><th>Versus</th><th>Who Declared</th><th>Available</th></tr>";
while($r=mysql_fetch_assoc($wq))
{
if($factiondata['factionID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; }
$d=date('F j, Y, g:i:s a',$r['warTIME']);
$ggq=mysql_query("SELECT * FROM factions WHERE factionID=".$r[$f]);
$them=mysql_fetch_assoc($ggq);
print "<tr><td>$d</td><td><a href='factions.php?action=view&ID={$them['factionID']}'><font color = red>{$them['factionNAME']}</font></a></td><td>$w</td> ";
	$cnt=mysql_query("SELECT * FROM users WHERE faction={$them['factionID']} AND hospital = 0 AND jail = 0");
print "<td><font color = green>".mysql_num_rows($cnt)."</font></td></tr>";
}
print "</table><hr width='100%'>";

$membcache.="<hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th colspan='11'>War Report For War Against: {$them['factionNAME']}</th></tr><tr><th>Nr.</th> <th>ID</th> <th>Name</th><th>Level</th><th>Money</th> <th>Location</th> <th>Ready To Be Attacked</th> <th>Hospital</th> <th>Reason</th> <th>Mail</th> <th>Attack</th></tr>";
$q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE faction=$f ORDER BY userid ASC");
$n=0;
while($r2=mysql_fetch_array($q))
{
if( $r2['hp'] >= 2 and (($r2['hospital'] == 0 and $ir['hospital']==0) || ($r2['hospital'] and $ir['hospital'])) and $r2['location'] == $ir['location']) { $color="green";$text="Yes"; } else
{ $color="red"; $text="No"; }
$n++;
if($r2['hospital']==0) { $r2['hospreason']=""; }
$membcache.="\n<tr><td>$n</td><td>{$r2['userid']}</td> <td><a href='viewuser.php?u={$r2['userid']}'>{$r2['username']}</a></td> <td>{$r2['level']}</td> <td>\${$r2['money']}</td> <td>{$r2['cityname']}</td> <td><span style='color:$color'>$text</span></td> <td>{$r2['hospital']} minute(s)</td> <td>{$r2['hospreason']}</td> <td>[<a href='mailbox.php?action=compose&ID={$r2['userid']}'>Send Mail</a>]</td> <td>[<a href='attack.php?ID={$r2['userid']}'>Attack</a>]</td></tr>";
}
$membcache.="</table><hr width='100%'><a href='yourfaction.php'>> Go Back</a><hr width='100%'>";



print $membcache;
}

 

error -

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/notl/public_html/yourfaction.php on line 1200

 

Line -

while($r2=mysql_fetch_array($q))

What is

$f

equal to?

The issue here is

$q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE faction=$f ORDER BY userid ASC");
Link to comment
Share on other sites

try

function faction_warview()
{
global $db,$ir,$c,$userid,$factiondata,$f;
$wq=mysql_query("SELECT * FROM factionwars WHERE warDECLARER={$ir['faction']} OR warDECLARED={$ir['faction']}");
   print "<b>These are the wars your faction is in.</b>
           <hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th>Time Started</th><th>Versus</th><th>Who Declared</th><th>Available</th></tr>";
while($r=mysql_fetch_assoc($wq))
{
if($factiondata['factionID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; }
$d=date('F j, Y, g:i:s a',$r['warTIME']);
$ggq=mysql_query("SELECT * FROM factions WHERE factionID=".$r[$f]);
$them=mysql_fetch_assoc($ggq);
   print "<tr><td>$d</td><td><a href='factions.php?action=view&ID={$them['factionID']}'><font color = red>{$them['factionNAME']}</font></a></td><td>$w</td> ";
       $cnt=mysql_query("SELECT * FROM users WHERE faction={$them['factionID']} AND hospital = 0 AND jail = 0");
   print "<td><font color = green>".mysql_num_rows($cnt)."</font></td></tr>";
}
   print "</table><hr width='100%'>";

$membcache.="<hr width='100%'><table width=100% cellspacing=1 class='table'><tr style='background:gray'><th colspan='11'>War Report For War Against: {$them['factionNAME']}</th></tr><tr><th>Nr.</th> <th>ID</th> <th>Name</th><th>Level</th><th>Money</th> <th>Location</th> <th>Ready To Be Attacked</th> <th>Hospital</th> <th>Reason</th> <th>Mail</th> <th>Attack</th></tr>";
$q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE faction=$f ORDER BY userid ASC");
$n=0;
while($r2=mysql_fetch_array($q))
{
if( $r2['hp'] >= 2 and (($r2['hospital'] == 0 and $ir['hospital']==0) || ($r2['hospital'] and $ir['hospital'])) and $r2['location'] == $ir['location']) { $color="green";$text="Yes"; } else
{ $color="red"; $text="No"; }
$n++;
if($r2['hospital']==0) { $r2['hospreason']=""; }
$membcache.="\n<tr><td>$n</td><td>{$r2['userid']}</td> <td><a href='viewuser.php?u={$r2['userid']}'>{$r2['username']}</a></td> <td>{$r2['level']}</td> <td>\${$r2['money']}</td> <td>{$r2['cityname']}</td> <td><span style='color:$color'>$text</span></td> <td>{$r2['hospital']} minute(s)</td> <td>{$r2['hospreason']}</td> <td>[<a href='mailbox.php?action=compose&ID={$r2['userid']}'>Send Mail</a>]</td> <td>[<a href='attack.php?ID={$r2['userid']}'>Attack</a>]</td></tr>";
}
$membcache.="</table><hr width='100%'><a href='yourfaction.php'>> Go Back</a><hr width='100%'>";



print $membcache;
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...