nikon Posted March 30, 2007 Share Posted March 30, 2007 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 More sharing options...
vbnullchar Posted March 30, 2007 Share Posted March 30, 2007 can you post the rest of the codes? Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218001 Share on other sites More sharing options...
nikon Posted March 30, 2007 Author Share Posted March 30, 2007 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; } ?> Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218008 Share on other sites More sharing options...
nikon Posted March 30, 2007 Author Share Posted March 30, 2007 *Bump* Its very important to me, This problem prevent from me to continue working on the system. Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218069 Share on other sites More sharing options...
Full-Demon Posted March 30, 2007 Share Posted March 30, 2007 Hmm, maybe you didnt closed one of the If/else tags above of that line? Difficult to see what it is because you dont use the fishtail programming structure. Cant see where the brackets close etc. Full-Demon Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218077 Share on other sites More sharing options...
neel_basu Posted March 30, 2007 Share Posted March 30, 2007 You have an Error On Line Number 70 Change enemy made dmg ."$def." With enemy made dmg .".$def." e.g. ".$def." Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218085 Share on other sites More sharing options...
nikon Posted March 30, 2007 Author Share Posted March 30, 2007 Thanks, Ill try it out immidiatly when my server will come back to work. And Full-Demon, I had an arrange structure but I delete all the spaces between lines. Next time I will bring an arranged code :] Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218103 Share on other sites More sharing options...
neel_basu Posted March 30, 2007 Share Posted March 30, 2007 Why not You install in your home php ?? Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218108 Share on other sites More sharing options...
nikon Posted March 30, 2007 Author Share Posted March 30, 2007 Because I prefer to work with outside servers Link to comment https://forums.phpfreaks.com/topic/44902-syntex-error-on-a-note/#findComment-218132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.