I wrote a script recently that I can't get error free. I tried to use multiple if / else/elseif statements and it errors out. I usually get an error like:
Parse error: syntax error, unexpected '{' in /home/tserv1l/public_html/original/files/quest.php on line 234
Or expecting '(' instead of '{' etc.
Anyone know the problem?
if ($action=="recruitkill")
{
$totalvthugs = "SELECT thugs FROM $prefix.user_characters WHERE nickname='$victim'";
$result = mysql_query($totalvthugs);
$result_array = mysql_fetch_array($result);
$totalathugs = "SELECT thugs FROM $prefix.user_characters WHERE nickname='$stats_array[nickname]'";
$result = mysql_query($totalathugs);
$result_array = mysql_fetch_array($result);
$totalaweapon = "SELECT ak47s FROM $prefix.user_characters WHERE nickname='$stats_array[nickname]'";
$result = mysql_query($totalathugs) ;
$result_array = mysql_fetch_array($result) ;
$totalvweapon = "SELECT ak47s FROM $prefix.user_characters WHERE nickname='$victim'";
$result = mysql_query($totalvthugs) ;
$result_array = mysql_fetch_array($result) ;
If ($totalvthugs <=0)
{
print "Your victim does not have any units to attack!";
} If ($totalathugs <=0){
echo "You do not have any units!";
} elseif ($totalaweapon >= $totalathugs) {
$totaldamageposa = $totalaweapon / 2.5;
} else ($totalaweapon == $totalathugs) {
$totaldamageposa = $totalaweapon /2.5;
} If ($totalaweapon <= $totalathugs) {
$totaldamageposa = $totalathugs /2.5;
} elseif ($totalvweapon >= $totalvthugs) {
$totaldamageposv = $totalvweapon / 2.5;
} elseif ($totalvweapon == $totalvthugs) {
$totaldamageposv = $totalvweapon /2.5;
} elseif ($totalvweapon <= $totalvthugs) {
$totaldamageposv = $totalvthugs /2.5;
} elseif ($totaldamageposa >= $totaldamageposv) {
$totalvunitskilled = ($totaldamageposa / $totaldamageposv;)
$totalaunitskilled = ($totaldamageposv / .$totaldamageposa;)
} elseif {$totaldamageposa <= $totaldamageposv) {
$totalvunitskilled = $totaldamageposv / $totaldamageposa;
$totalaunitskilled = $totaldamageposa / .$totaldamageposv;
} else {
$query = "UPDATE $prefix.user_characters SET item_thug=item_thug-$totalaunitskilled WHERE nickname='$victim'";
$result = mysql_query($query);
$query = "UPDATE $prefix.user_characters SET item_thug=item_thug-$totalvunitskilled WHERE nickname='" . $stats_array["nickname"] . "'";
$result = mysql_query($query);
send_news($victim,"" . $stats_array["nickname"] . " and his recruits drove by your house and gunned down $" . number_format($totalaunitskilled) . ".");
gain_exp($stats_array["nickname"],15,150);
echo "<center>You killed $" . number_format($totalvunitskilled) . ".</center><br>";
$query = "UPDATE $prefix.user_characters SET tokens=tokens-$attackcost WHERE nickname='" . $stats_array["nickname"] . "'";
$result = mysql_query($query);
}
else
{
echo "<center>Your attempt at killing units failed.</center><br>";
gain_exp($stats_array["nickname"],2,100);
$query = "UPDATE $prefix.user_characters SET tokens=tokens-$attackcost WHERE nickname='" . $stats_array["nickname"] . "'";
$result = mysql_query($query);
}
}}