Jump to content

always same result


grlayouts

Recommended Posts

i have a game script and it's always bringing back the same result and i cant see why..

 

all i get when the script it ran is

 

[/code]echo '<div class=noticeBox><h2>Sorry! No available member found![/code]

 

the code is below and can provide the functions and db if needed, but cant see what's wrong.

 

<?php

include '../header.php'; 

echo '<div id=AjaxSubDiv>';
echo '<div id="actionDiv">';

include '../statusbar.php';

echo '<div id=contentBox>';

	// Show Fight Result
	if( !empty($_GET[action]) AND $_GET[action]=='attack' ) {
		echo $str;	


	// Fight Lists
	echo '<P class=pageheader>Fight</P>';
	echo '<P>Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything...</P>';

	$res = query("SELECT COUNT(*) FROM `usertable` WHERE `userid`!=$user");
	list($total) = mysql_fetch_array($res);
	if( $total>0 ) {

		$res = query("SELECT * FROM `usertable` WHERE `userid`!=$user LIMIT 0,20");




			$viewplayer = Player::getById($row[userid]);

			echo '<tr>';
			echo '<td width=120px>';
				echo '<P class=titleP><a href="#" onclick="load_menu_val(\'AjaxSubDiv\', \'profile\', '.$row[userid].');return false;"><fb:profile-pic uid="'.$row[userid].'" size="square" linked="false" width="75px" class="userImg" /></a></P>';
				echo '<P class=titleP><a href="#" onclick="load_menu_val(\'AjaxSubDiv\', \'profile\', '.$row[userid].');return false;"><fb:name uid="'.$row[userid].'" linked="false" /></a></P>';
			echo '</td>';

			echo '<td width=120px>';
				echo '<P><B>Level:</B> '.$viewplayer->level.', '.get_level_title($player->level).'</P>';
			echo '</td>';

			echo '<td width=120px>';
				echo '<P><B>Crew:</B> '.$viewplayer->crew.'</P>';
		echo '</td>';

		echo '<td width=300px>';
			if( $viewplayer->health > 20 ) {
				echo '<form id="FightForm'.$row[userid].'" method="POST" class="itemForm">';
				echo '<input type=hidden name=user value="'.$user.'">';
				echo '<input type=hidden name=opid value="'.$row[userid].'">';
				echo '<input type=hidden name=action value="dofight">';
				echo '<P><input type=button onclick="do_submit(\'FightForm'.$row[userid].'\',\'http://www.bofs.us/thief/thiefmaster/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Now" class="submitButton" /></P>';
				echo '</form>';
			}
			else {
				echo '<P class=titleP>Too Weak To Fight</P>';
			}
		echo '</td>';
		echo '</tr>';
	}
	echo '</table>';
	echo '</center>';
}
else {
	echo '<div class=noticeBox><h2>Sorry! No available member found!</h2></div>';
	print"$res";

}

echo '</div>'; // end of contentBox

echo '</div>'; // end of actiondiv
echo '</div>'; // end of AjaxSubDiv


?>



Link to comment
Share on other sites

The first thing I'd do is to update this line

if( !empty($_GET[action]) AND $_GET[action]=='attack' ) {

 

to

if($_GET[action]=='attack' ) {

 

Just to simplify. See what that gets you.

 

If that doesn't work try echoing the $_GET[action]. Also add "'" marks i.e. $_GET['action']

 

Link to comment
Share on other sites

tried echoing it and it's not bringing up anything at all..

 

echo $_GET["action"]=='attack'; 

 

db

 

uid 	userid 	uCash 	uBankCash 	uPoint 	uSkillsMax 	uSkills 	uAttr 	uCharName 	uCharType 	uStat
1 	100000917825988 	2990 	0 	0 	100-10-3 	100-10-3-10-10 	1-32-1-10 	  	1 	8-0-0-0-0
6 	100000180079544 	570 	0 	0 	100-10-3 	100-10-3-10-10 	1-2-1-10 	  	1 	1-0-0-0-0

Link to comment
Share on other sites

incase it matters, this is the fightinc

 

<?php

//====================================
// Do Fight
//====================================
function do_fight( $u, $op ) {

global $facebook;
global $appCanvasUrl;
global $appCallbackUrl;
global $appTitle;

$player1 = Player::getById($u);
$player2 = Player::getById($op);

// ================================================================================
// The User Part
// ================================================================================

$userTotalAttPwr = 0;
$userTotalDefPwr = 0;

// ========================================
// Search and Count User Attack Weapons
// ========================================
$res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");
list($total) = mysql_fetch_array($res);

if( $total>0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");
	while( $row = mysql_fetch_array($res) ) {
		$userTotalWep += $row[itemAmount];
	}
}

if( $userTotalWep > 0 ) {
	if( $userTotalWep >= $player1->crew ) $userWepUse = $player1->crew;
	else $userWepUse = $userTotalWep;
}
else $userWepUse = 0;

// ========================================
// Collect and Sort Attack Weapon Power
// ========================================

if( $userTotalWep > 0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");

	$rows = 0;
	while( $row = mysql_fetch_array($res) ) {
		$item = Item::getById($row[itemId]);

		$userWepArray[$rows][id] =  $item->id;
		$userWepArray[$rows][img] =  $item->image;
		$userWepArray[$rows][att] =  $item->att;
		$userWepArray[$rows][def] =  $item->def;
		$rows++;
		if( $row[itemAmount] > 1 ) {
			for($i=0; $i<($row[itemAmount]-1); $i++ ) {
				$userWepArray[$rows][id] =  $item->id;
				$userWepArray[$rows][img] =  $item->image;
				$userWepArray[$rows][att] =  $item->att;
				$userWepArray[$rows][def] =  $item->def;
				$rows++;	
			}
		}
	}

	// Sort The Array
	for( $j=0; $j<$userTotalWep; $j++ ) {
		for( $i=0; $i<($userTotalWep-1); $i++ ) {
			if( $userWepArray[$i][att] < $userWepArray[$i+1][att] ) {
				$tempArray = $userWepArray[$i];
				$userWepArray[$i] = $userWepArray[$i+1];
				$userWepArray[$i+1] = $tempArray;
			}
		}
	}

	$userWepArray = array_slice($userWepArray,0,$userWepUse);

	for( $i=0; $i<$userWepUse; $i++ ) {
		$userTotalAttPwr += $userWepArray[$i][att];
		$userTotalDefPwr += $userWepArray[$i][def];
	}
}


// ========================================
// Search and Count User Defense Weapons
// ========================================
$res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$u AND `itemType`=2");
list($total) = mysql_fetch_array($res);

if( $total>0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND `itemType`=2");
	while( $row = mysql_fetch_array($res) ) {
		$userTotalDef += $row[itemAmount];
	}
}

if( $userTotalDef > 0 ) {
	if( $userTotalDef >= $player1->crew ) $userDefUse = $player1->crew;
	else $userDefUse = $userTotalDef;
}
else $userDefUse = 0;

// ========================================
// Collect and Sort Defense Weapon Power
// ========================================

if( $userTotalDef > 0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$u AND `itemType`=2");

	$rows = 0;
	while( $row = mysql_fetch_array($res) ) {
		$item = Item::getById($row[itemId]);

		$userDefArray[$rows][id] =  $item->id;
		$userDefArray[$rows][img] =  $item->image;
		$userDefArray[$rows][att] =  $item->att;
		$userDefArray[$rows][def] =  $item->def;
		$rows++;
		if( $row[itemAmount] > 1 ) {
			for($i=0; $i<($row[itemAmount]-1); $i++ ) {
				$userDefArray[$rows][id] =  $item->id;
				$userDefArray[$rows][img] =  $item->image;
				$userDefArray[$rows][att] =  $item->att;
				$userDefArray[$rows][def] =  $item->def;
				$rows++;	
			}
		}
	}

	// Sort The Array
	for( $j=0; $j<$userTotalDef; $j++ ) {
		for( $i=0; $i<($userTotalDef-1); $i++ ) {
			if( $userDefArray[$i][att] < $userDefArray[$i+1][att] ) {
				$tempArray = $userDefArray[$i];
				$userDefArray[$i] = $userDefArray[$i+1];
				$userDefArray[$i+1] = $tempArray;
			}
		}
	}

	$userDefArray = array_slice($userDefArray,0,$userDefUse);

	for( $i=0; $i<$userDefUse; $i++ ) {
		$userTotalAttPwr += $userDefArray[$i][att];
		$userTotalDefPwr += $userDefArray[$i][def];
	}
}


// ================================================================================
// Now The Opponents Part
// ================================================================================

$opTotalAttPwr = 0;
$opTotalDefPwr = 0;

// ========================================
// Search and Count Opponents Attack Weapons
// ========================================
$res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");
list($total) = mysql_fetch_array($res);

if( $total>0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");
	while( $row = mysql_fetch_array($res) ) {
		$opTotalWep += $row[itemAmount];
	}
}

if( $opTotalWep > 0 ) {
	if( $opTotalWep >= $player2->crew ) $opWepUse = $player2->crew;
	else $opWepUse = $opTotalWep;
}
else $opWepUse = 0;

// ========================================
// Collect and Sort Attack Weapon Power
// ========================================

if( $opTotalWep > 0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND (`itemType`=1 OR `itemType`=4 OR `itemType`=5)");

	$rows = 0;
	while( $row = mysql_fetch_array($res) ) {
		$item = Item::getById($row[itemId]);

		$opWepArray[$rows][id] =  $item->id;
		$opWepArray[$rows][img] =  $item->image;
		$opWepArray[$rows][att] =  $item->att;
		$opWepArray[$rows][def] =  $item->def;
		$rows++;
		if( $row[itemAmount] > 1 ) {
			for($i=0; $i<($row[itemAmount]-1); $i++ ) {
				$opWepArray[$rows][id] =  $item->id;
				$opWepArray[$rows][img] =  $item->image;
				$opWepArray[$rows][att] =  $item->att;
				$opWepArray[$rows][def] =  $item->def;
				$rows++;	
			}
		}
	}

	// Sort The Array
	for( $j=0; $j<$opTotalWep; $j++ ) {
		for( $i=0; $i<($opTotalWep-1); $i++ ) {
			if( $opWepArray[$i][att] < $opWepArray[$i+1][att] ) {
				$tempArray = $opWepArray[$i];
				$opWepArray[$i] = $opWepArray[$i+1];
				$opWepArray[$i+1] = $tempArray;
			}
		}
	}

	$opWepArray = array_slice($opWepArray,0,$opWepUse);

	for( $i=0; $i<$opWepUse; $i++ ) {
		$opTotalAttPwr += $opWepArray[$i][att];
		$opTotalDefPwr += $opWepArray[$i][def];
	}
}


// ========================================
// Search and Count User Defense Weapons
// ========================================
$res = query("SELECT COUNT(*) FROM `items_log` WHERE `userid`=$op AND `itemType`=2");
list($total) = mysql_fetch_array($res);

if( $total>0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND `itemType`=2");
	while( $row = mysql_fetch_array($res) ) {
		$opTotalDef += $row[itemAmount];
	}
}

if( $opTotalDef > 0 ) {
	if( $opTotalDef >= $player2->crew ) $opDefUse = $player2->crew;
	else $opDefUse = $opTotalDef;
}
else $opDefUse = 0;

// ========================================
// Collect and Sort Defense Weapon Power
// ========================================

if( $opTotalDef > 0 ) {
	$res = query("SELECT * FROM `items_log` WHERE `userid`=$op AND `itemType`=2");

	$rows = 0;
	while( $row = mysql_fetch_array($res) ) {
		$item = Item::getById($row[itemId]);

		$opDefArray[$rows][id] = $item->id;
		$opDefArray[$rows][img] = $item->image;
		$opDefArray[$rows][att] = $item->att;
		$opDefArray[$rows][def] = $item->def;
		$rows++;
		if( $row[itemAmount] > 1 ) {
			for($i=0; $i<($row[itemAmount]-1); $i++ ) {
				$opDefArray[$rows][id] = $item->id;
				$opDefArray[$rows][img] = $item->image;
				$opDefArray[$rows][att] = $item->att;
				$opDefArray[$rows][def] = $item->def;
				$rows++;	
			}
		}
	}

	// Sort The Array
	for( $j=0; $j<$opTotalDef; $j++ ) {
		for( $i=0; $i<($opTotalDef-1); $i++ ) {
			if( $opDefArray[$i][att] < $opDefArray[$i+1][att] ) {
				$tempArray = $opDefArray[$i];
				$opDefArray[$i] = $opDefArray[$i+1];
				$opDefArray[$i+1] = $tempArray;
			}
		}
	}

	$opDefArray = array_slice($opDefArray,0,$opDefUse);

	for( $i=0; $i<$userDefUse; $i++ ) {
		$opTotalAttPwr += $opDefArray[$i][att];
		$opTotalDefPwr += $opDefArray[$i][def];
	}
}



// ================================================================================
// Power Comparison
// ================================================================================

$userTotalAttPwr += $player1->attack;
$userTotalDefPwr += $player1->defense;

$opTotalAttPwr += $player2->attack;
$opTotalDefPwr += $player2->defense;

$userPoint = ($userTotalAttPwr - $opTotalDefPwr);
$oponentPoint = ($opTotalAttPwr - $userTotalDefPwr);

if( $userPoint > $oponentPoint ) {
	$str = '<div class=noticeBox><P class=successP>You Won!</P>';

	if( $player2->cash > 0 ) $userCashEarn = rand(1,$player2->cash);
	else $userCashEarn = 0;
	$userExpEarn = rand(1,5);
	$userHealthLoss = rand(5,10);
	$oponentExpEarn = rand(1,5);
	$oponentHealthLoss = rand(5,10);

	$player1->cash += $userCashEarn;
	$player1->exp += $userExpEarn;
	$player1->stamina -= 1;
	$player1->health -= $userHealthLoss;
	$player1->win += 1;
	$player2->cash -= $userCashEarn;
	$player2->exp += $oponentExpEarn;
	$player2->health -= $oponentHealthLoss;
	$player2->lose += 1;

	$player1->save();
	$player2->save();


	// Stream Publish
	$message = 'won a fight at '.$appTitle.' and received $'.number_format($userCashEarn,0).' and '.$userExpEarn.' exp!';
	$caption = 'Are you strong enough to fight?';
	$desc = 'Join Whos The Thief, Become the master thief and show your tactics...';
	$picture = $appCallbackUrl.'images/logo.png';
	publishMyStream($message, $appTitle, $caption, $appCanvasUrl, $desc, $picture );

	$logText = 'You won a fight against <fb:name uid='.$op.' useyou=false linked=false />. You earned <B>$'.number_format($userCashEarn,0).' cash</B> and '.$userExpEarn.' exp!';
	add_news( $logText, $u );

	$logText = 'You lost a fight against <fb:name uid='.$u.' useyou=false linked=false />. You lost <B>$'.number_format($userCashEarn,0).' cash</B> and earned <B>'.$oponentExpEarn.' exp</B>!';
	add_news( $logText, $op );

}	

else {
	$str = '<div class=noticeBox><P class=failP>You Lost!</P>';

	if( $player1->cash > 0 ) $oponentCashEarn = rand(1,$player1->cash);
	else $oponentCashEarn = 0;
	$userExpEarn = rand(1,5);
	$userHealthLoss = rand(5,10);
	$oponentExpEarn = rand(1,5);
	$oponentHealthLoss = rand(5,10);

	$player1->cash -= $oponentCashEarn;
	$player1->exp += $userExpEarn;
	$player1->stamina -= 1;
	$player1->health -= $userHealthLoss;
	$player1->lose += 1;
	$player2->cash += $oponentCashEarn;
	$player2->exp += $oponentExpEarn;
	$player2->health -= $oponentHealthLoss;
	$player2->win += 1;

	$player1->save();
	$player2->save();

	// Stream Publish
	$message = 'lost a fight at '.$appTitle.' and lost $'.number_format($oponentCashEarn,0).'!';
	$caption = 'Are you strong enough to fight?';
	$desc = 'Join Whos The Thief, Become the master thief and show your tactics...';
	$picture = $appCallbackUrl.'images/logo.png';
	publishMyStream($message, $appTitle, $caption, $appCanvasUrl, $desc, $picture );

	$logText = 'You lost a fight against <fb:name uid='.$op.' useyou=false linked=false />. You lost <B>$'.number_format($oponentCashEarn,0).' cash</B> and earned <B>'.$userExpEarn.' exp</B>!';
	add_news( $logText, $u );

	$logText = 'You won a fight against <fb:name uid='.$u.' useyou=false linked=false />. You earned <B>$'.number_format($oponentCashEarn,0).' cash</B> and <B>'.$oponentExpEarn.' exp</B>!';
	add_news( $logText, $op );

}	

$str .= '<table class="fightTable">';
$str .= '<tr>';
$str .= '<td width=50% valign=top>';

	$str .= '<table class="fightTable">';
	$str .= '<tr>';
		$str .= '<td width=60px><P><fb:profile-pic uid='.$u.' size=square linked=false /></P></td>';
		$str .= '<td>';
		$str .= '<P class=titleP><fb:name uid='.$u.' linked=false /></P>';
		if( $player1->charname != "" ) 
			$str .= '<P>'.$player1->charname.'</P>';
		$str .= '<P>Crew: '.$player1->crew.'</P>';
		$str .= '</td>';
	$str .= '</tr>';
	$str .= '</table>';

$str .= '<td width=50% valign=top>';

	$str .= '<table class="fightTable">';
	$str .= '<tr>';
		$str .= '<td>';
		$str .= '<P class=rightTitleP><fb:name uid='.$op.' linked=false /></P>';
		if( $player2->charname != "" ) 
			$str .= '<P class=rightP>'.$player2->charname.'</P>';
		$str .= '<P class=rightP>Crew: '.$player2->crew.'</P>';
		$str .= '</td>';
		$str .= '<td width=60px><P><fb:profile-pic uid='.$op.' size=square linked=false /></P></td>';
	$str .= '</tr>';
	$str .= '</table>';

$str .= '</td>';
$str .= '</tr>';

$str .= '<tr>';
$str .= '<td width=50% valign=top>';

	$str .= '<table class="fightTable">';
	$str .= '<tr><td colspan=5><P class=titleP>Offensive Items</P></td></tr>';
	$str .= '<tr>';
	if( $userWepUse>0 ) {
		for( $i=0; $i<$userWepUse; $i++ ) {

			$item = Item::getById($userWepArray[$i][id]);
			$str .= '<td><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>';
			$totalUse = 1;
			for( $j=$i; $j<$userWepUse; $j++ ) {
				if( $userWepArray[$i][id] == $userWepArray[$i+1][id] ) {
					$totalUse++;
					$i++;
				}
			}
			$str .= '<P>X'.$totalUse.'</P></td>';
		}
	}		
	else {
		$str .= '<td colspan=5><P>You had no offensive item and faught with empty hands!</P></td>';
	}
	$str .= '</tr>';

	$str .= '<tr><td colspan=5><P class=titleP>Defensive Items</P></td></tr>';
	$str .= '<tr>';
	if( $userDefUse>0 ) {

		for( $i=0; $i<$userDefUse; $i++ ) {
			$item = Item::getById($userDefArray[$i][id]);
			$str .= '<td><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>';
			$totalUse = 1;
			for( $j=$i; $j<$userDefUse; $j++ ) {
				if( $userDefArray[$i][id] == $userDefArray[$i+1][id] ) {
					$totalUse++;
					$i++;
				}
			}
			$str .= '<P>X'.$totalUse.'</P></td>';
		}
	}		
	else {
		$str .= '<td colspan=5><P>You had no defensive item and faught with empty hands!</P></td>';
	}
	$str .= '</tr>';
	$str .= '</table>';

$str .= '</td>';
$str .= '<td valign=top align=right>';

	$str .= '<table class="fightTable">';
	$str .= '<tr><td colspan=5><P class=rightTitleP>Offensive Items</P></td></tr>';
	$str .= '<tr>';
	if( $opWepUse>0 ) {

		for( $i=0; $i<$opWepUse; $i++ ) {
			$item = Item::getById($opWepArray[$i][id]);
			$str .= '<td align=right><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>';
			$totalUse = 1;
			for( $j=$i; $j<$opWepUse; $j++ ) {
				if( $opWepArray[$i][id] == $opWepArray[$i+1][id] ) {
					$totalUse++;
					$i++;
				}
			}
			$str .= '<P>X'.$totalUse.'</P></td>';
		}
	}		
	else {
		$str .= '<td colspan=5><P class=rightP><fb:name uid="'.$op.'" firstnameonly=true linked=false /> had no offensive item and faught with empty hands!</P></td>';
	}
	$str .= '</tr>';
	$str .= '<tr><td colspan=5><P class=rightTitleP>Defensive Items</P></td></tr>';
	$str .= '<tr>';
	if( $opDefUse>0 ) {
		for( $i=0; $i<$opDefUse; $i++ ) {
			$item = Item::getById($opDefArray[$i][id]);
			$str .= '<td align=right><img src="'.$appCallbackUrl.'images/items/'.$item->image.'" class="imgbox" width=50 height=50>';
			$totalUse = 1;
			for( $j=$i; $j<$opDefUse; $j++ ) {
				if( $opDefArray[$i][id] == $opDefArray[$i+1][id] ) {
					$totalUse++;
					$i++;
				}
			}
			$str .= '<P>X'.$totalUse.'</P></td>';
		}
	}		
	else {
		$str .= '<td colspan=5><P class=rightP><fb:name uid="'.$op.'" firstnameonly=true linked=false /> had no defensive item and faught with empty hands!</P></td>';
	}

	$str .= '</tr>';
	$str .= '</table>';

$str .= '</td>';
$str .= '</tr>';

$str .= '<tr>';
$str .= '<td>';
	$str .= '<BR><P class=successP><font size=4>Rewards!</font></P>';
	if( $userPoint > $oponentPoint ) {
		$str .= '<P class=titleP>+ $'.number_format($userCashEarn,0).'</P>';
		$str .= '<P class=titleP>+ '.number_format($userExpEarn,0).' exp</P>';
	}
	else {
		$str .= '<P class=titleP>- $'.number_format($oponentCashEarn,0).'</P>';
		$str .= '<P class=titleP>+ '.number_format($userExpEarn,0).' exp</P>';
	}
$str .= '</td>';
$str .= '<td>';

$str .= '<form id="DoFightForm" method="POST" class="itemForm">';
$str .= '<input type=hidden name=user value="'.$u.'">';
$str .= '<input type=hidden name=opid value="'.$op.'">';
$str .= '<input type=hidden name=action value="dofight">';
$str .= ' <input type=button onclick="do_submit(\'DoFightForm\',\'http://www.bofs.us/thief/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Again" class="submitButton" /></P>';
$str .= '</form>';

$str .= '</td>';
$str .= '</tr>';
$str .= '</table>';

$str .= '</div>';

return $str;

}



?>

Link to comment
Share on other sites

Ok, that's good. That means that this is more than likely where the error is.

 

So to go through it slowly.

 

In your code there is an IF statement

if( !empty($_GET[action]) AND $_GET[action]=='attack' ) {

 

If this IF statement fails then you get dumped out at the error message. This is what is happening.

 

So, back to the IF. The IF is checking that the GET variable is set and then is set to attack.

Firstly, you only really need the second part because if it's empty it can't be set to attack.

 

Now, it looks to me that the GET variable is not being set or passed to the page.

 

Apologies upfront if I'm teaching you to suck eggs but...

 

GET Variables get passed in the URL of the page. In the URL in your browser can you see a bit that says 'action=attack'

 

If so then you are not referencing it correctly. If not then the variable is either not being set or it's a $_POST variable.

 

Have a look at that and come back.

 

ATB

Link to comment
Share on other sites

The issue is definitely that the $_GET['action'] variable is not being set.

 

I know nothing of facebook to be honest.

 

Looking at your INC code nothing sets that variable to attack. Obviously it could come from somewhere else.

 

There is a form at the end of the code

$str .= '<form id="DoFightForm" method="POST" class="itemForm">';
$str .= '<input type=hidden name=user value="'.$u.'">';
$str .= '<input type=hidden name=opid value="'.$op.'">';
$str .= '<input type=hidden name=action value="dofight">';
$str .= ' <input type=button onclick="do_submit(\'DoFightForm\',\'http://www.bofs.us/thief/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Again" class="submitButton" /></P>';
$str .= '</form>';

 

I believe this is where your attack variable is being set.

$str .= '<input type=hidden name=action value="dofight">';

 

Obviously this is it being set to 'dofight' rather than 'attack' but this variable is a $_POST variable, this leads me to believe that the other one will be too.

 

Try replacing

if( !empty($_GET[action]) AND $_GET[action]=='attack' ) {

 

with

if($_POST['action'] == 'attack'){

Link to comment
Share on other sites

if i remove the problem code that jumps the incorrect result the error i get it

 


Fight

Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 IN SELECT * FROM `usertable` WHERE `userid`= 

 

postfight php

 

<?php



include '../header.php'; 



if( $_POST[action] == 'dofight' ) {



$player = Player::getById($_POST[user]);



if( $player->stamina <= 0 ) {

	$str = '<div class=noticeBox><P class=failP>Failure!</P><H2>You are not strong enough to fight against <fb:name uid="'.$_POST[opid].'" linked=false />! Try back later...</H2></div>';

}

else if( $player->health < 20 ) {

	$str = '<div class=noticeBox><P class=failP>Failure!</P><H2>You are too weak to fight <fb:name uid="'.$_POST[opid].'" linked=false />! Try back later...</H2></div>';

}

else {

	$str = do_fight( $_POST[user], $_POST[opid] );

}

}



include '../statusbar.php';



echo '<div id=contentBox>';



	// Show Fight Result

	if( !empty($_GET[action]) AND $_GET[action]=='attack' ) {

		echo $str;	

	}

	if( $_POST[action] == 'dofight' ) {

		echo $str;	

	}



	// Fight Lists

	echo '<P class=pageheader>Fight</P>';

	echo '<P>Its time for action! Fight with rival thieves and grab their cash. You will require 1 strength for each fight and you will gain some cash and exp if you win the fight. However you will just earn some exp if you loose!! Each fight will decrease your health so keep an eye on health level because if your health goes below zero you will die and loose everything...</P>';



	$res = query("SELECT COUNT(*) FROM `usertable` WHERE `userid`!=$user");

	list($total) = mysql_fetch_array($res);

	if( $total>0 ) {



		$res = query("SELECT * FROM `usertable` WHERE `userid`!=$user LIMIT 0,20");



		echo '<center>';

		echo '<table class="itemTable">';

		while( $row = mysql_fetch_array($res) ) {



			$viewplayer = Player::getById($row[userid]);



			echo '<tr>';



			echo '<td width=120px>';

				echo '<P><B>Level:</B> '.$viewplayer->level.', '.get_level_title($player->level).'</P>';

			echo '</td>';



			echo '<td width=120px>';

				echo '<P><B>Crew:</B> '.$viewplayer->crew.'</P>';

		echo '</td>';



		echo '<td width=300px>';

			if( $viewplayer->health > 20 ) {

				echo '<form id="FightForm'.$row[userid].'" method="POST" class="itemForm">';

				echo '<input type=hidden name=user value="'.$user.'">';

				echo '<input type=hidden name=opid value="'.$row[userid].'">';

				echo '<input type=hidden name=action value="dofight">';

				echo '<P><input type=button onclick="do_submit(\'FightForm'.$row[userid].'\',\'http://www.bofs.us/thief/fight/post_fight.php\', \'actionDiv\'); return false;" value="Fight Now" class="submitButton" /></P>';

				echo '</form>';

			}

			else {

				echo '<P class=titleP>Too Weak To Fight</P>';

			}

		echo '</td>';

		echo '</tr>';

	}

	echo '</table>';

	echo '</center>';

}

else {

	echo '<div class=noticeBox><h2>Sorry! No available member found!</h2></div>';

}



echo '</div>'; // end of contentBox



?>

Link to comment
Share on other sites

I think so yes.

 

I'm not suggesting that you remove the IF statement just modify it.

 

As I say you IF statement is checking for the variable $_GET['action'] to equal 'attack'

 

We have proved by echoing that variable, that it isn't set at all let alone set to 'attack'

 

You need to go back in the code to where you are setting the variable to attack and check it out as I don't believe this is actually being set.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.