Jump to content

Syntex error on a "note"


nikon

Recommended Posts

Hi you all,

 

I started to work on a new system, all the things was ok

until I got this error:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/****/domains/****/public_html/pw/name.php on line 33

 

Well, as I know from my old experience that means in the most of the cases that I forgot

a ";" at the end of a command.

 

I opened the file, looking over and over, and no - I dont find any logic in this error.

Heres the code:

$atk = caculate_atk($atkrate);
$def = caculate_def($defrate);

if($atk>$def){

//Caculate the Gain

$percent['max']=100;
$percent['min']=50;

 

Line 33:

//Caculate the Gain

 

 

Why this error epears? my code just fine...so why?

 

 

Thanks for any possiable help.

Link to comment
https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/
Share on other sites

Amm yea, but its a big file, so shall I give the code that above?

 

The all code.

 

Lines 0-120

<?php
//attack.PHP
if(array_key_exists('do_attack',$_POST)){

$turns = (int)$_POST['turns'];
$defid = (int)$_GET['id'];
//Check if the victim actually exists
//Remember: Vaction Mode
$Check = mysql_query("SELECT * FROM members WHERE id='$defid' AND `status` <> 'vm' ");
$exists = mysql_num_rows($Check);
$definfo = mysql_Fetch_array($Check);

if($turns > $user['turns'] || $turns == 0 || $turns > 10 || $exists < 1 || $defid == $user['id']){
echo "<b>שגיאה</b><br />";
if($turns > $user['turns']) echo "Cheat";
if($turns == 0 || $turns > 10) echo "Cheat";
if($exists < 1) echo "Cheat";
if($defid == $user['id']) echo "Cheat";
}else{
$def_def=build_defs_arrray($defid);
$user_ships=build_ships_array($user['id']);


foreach($user_ships as $amount=>$dmg) $atkrate=$atkrate+$amount*$dmg;
foreach($def_def as $amount=>$dmg) $defrate=$defrate+$amount*$dmg;


$atk = caculate_atk($atkrate);
$def = caculate_def($defrate);

if($atk>$def){

//Caculate the Gain

$percent['max']=100;
$percent['min']=50;
$percentage = (int)sqrt(sqrt(mt_rand(pow($percent['min'],4),pow($percent['max'],4))));
$money = (int)$percentage*$turns*$user['metal']/1000;
mysql_query("UPDATE members SET metal=metal+'$money' WHERE id='{$user['id']}'");
mysql_query("UPDATE members SET metal=metal-'$money' WHERE id='$defid'");
    $turn2 = $turns-0.75;
	$points = $definfo['exp'] / 10;
	$pointgain1 = $points * $turns;
	$pointgain2 = $points * $turn2;
	$pointgain1 = (int) $pointgain1;
	$pointgain2 = (int) $pointgain2;
	$pointsgainf = mt_rand($pointgain2, $pointgain1);
	$pointsgain = $pointsgainf + $user['exp'];
	mysql_query("UPDATE members SET exp='$pointsgain' WHERE id='{$user['id']}");
	$pointslost = $definfo['exp'] - $pointsgainf;
	mysql_query("UPDATE members SET exp='$pointslost' WHERE id='$defid'");

$status = "<span style='color:green'>Won</span>";	
}else{
$pointsgainf = 0;
$money = 0;
$status = "<span style='color:red'>Lost</span>";
}

$time = time();
//Update this Turns
mysql_query("UPDATE members SET turns = turns-'$turns' WHERE id='{$user['id']}'");
mysql_query("INSERT INTO logs(`time`,`type`,atk,def,metal,exp,attacker,defender) 
VALUES('$time','attack','$atk','$def','$money','$pointsgainf','{$user['id']}','$defid')")or die(mysql_error());
echo $status." against ".$definfo['username']."!
<br />
<br />
you made dmg ".$atk."
<br />
enemy made dmg ."$def."
<br /><br />
you earned
".$money."
and gained
".$pointsgainf."
exp.
<br />";

}

}else{

do_attack_form();

}




function do_attack_form(){
echo "
<form method='post'>
   מס. תורות: (max. 10)<input type='text' name='turns'>
   <br />
   <input type='submit' name='do_attack'>
</form>
";
}


function caculate_def($defrate){
$defrate=(int)$defrate;
$defran=mt_rand(5,10);
$def=$defrate*$defran;
return $def;
}

function caculate_atk($atkrate){

$atkrate=(int)$atkrate;
$atkran=mt_rand(5,10);
$atk=$atkrate*$atkran;

return $atk;
}


?>


Archived

This topic is now archived and is closed to further replies.

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