i cant figure out what is wrong with this part of the script
function gang_warview()
{
global $db, $ir, $c, $userid, $gangdata;
$wq =
$db->query(
"SELECT *
FROM `gangwars`
WHERE `warDECLARER` = {$ir['gang']}
OR `warDECLARED` = {$ir['gang']}");
echo "<b>These are the wars your gang is in.</b><br />
<table width='75%' cellspacing='1' class='table'>
<tr>
<th>Time Started</th>
<th>Versus</th>
<th>Who Declared</th>
</tr>";
while ($r = $db->fetch_row($wq))
{
if ($gangdata['gangID'] == $r['warDECLARER'])
{
$w = 'You';
$f = 'warDECLARED';
}
else
{
$w = 'Them';
$f = 'warDECLARER';
}
$d = date('F j, Y, g:i:s a', $r['warTIME']);
$ggq =
$db->query(
"SELECT `gangID`, gangNAME`
FROM `gangs`
WHERE `gangID` = " . $r[$f]);
$them = $db->fetch_row($ggq);
echo "<tr>
<td>$d</td>
<td>
<a href='gangs.php?action=view&ID={$them['gangID']}'>
{$them['gangNAME']}
</a>
</td>
<td>$w</td>
</tr>";
}
echo "</table>";
}