2013-08-27 5 views
-4

여기에 전체 코드가 있습니다.이 코드는 elseif를 elseif로, elseif를 elseif로했을 때 완벽하게 작동합니다.임의의 이벤트에서 ElseIf Else 오류가 발생하는 경우

하지만 무엇보다도 먼저 if 문을 실행해야합니다. 그런 식으로 최소 회전 수가 적 으면 계속 소리내어 울리지 않을 것입니다. 여기 내가 점점 오전 오류 ... 구문 분석 오류입니다 :

<?php 

$ingame = "*"; 
require 'includes/header.php'; 
include 'includes/modzoideditables.php'; 
include 'includes/zoideditables.php'; 
include 'includes/offdefvalues.php'; 
$turns = 5; 
$turns2 = 10; 
$zoidmany = 1; 
$zoidmany2 = 2; 
$excav1 = 1; 
$excav2 = 0; 
$goldgive1 = 500; 
$goldgive2 = 700; 
$goldgive3 = 1000; 
$goldgive4 = 1500; 
$goldgive5 = 2000; 
$fight1 = 20000; 
$fight2 = 27000; 
$fight3 = 31000; 
$goldtake1 = 250; 
$goldtake2 = 500; 
$goldtake3 = 750; 
$goldtake4 = 1000; 
$miner = 5; 

    $rand = rand(1, 22); 
if ($turns > $user['uAttackTurns']) { 
     echo "You don't have enough turns."; 
} 
    $rand = rand(1, 22); 
elseif ($excav1 > $user['uExcavation2']) { 
} 
    else ($rand == 1) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uGatlingzaberfangweap=uGatlingzaberfangweap+$zoidmany,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/>You decide to keep it!</b></center><br /><?php 
    } 
    else ($rand == 2) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uGatlingzaberfangweap=uGatlingzaberfangweap+$zoidmany2,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany2?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/>You decide to keep it!</b></center><br /><?php 

     } 
     elseif ($excav2 = $user['uExcavation2']) { 
} 
    else ($rand == 1) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
    ?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 
    } 
    else ($rand == 2) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany2?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 

    } 
      elseif ($rand == 3) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uWeapon42=uWeapon42+$zoidmany,uAttackTurns=uAttackTurns+'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>You see something shiny in the distance, What is that you wonder?</b></center><br /><?php 
     ?><center><b>You just found a fully working <?=$wp_42_nm?>!<img src="<?=$wp_42_image?>"/></b></center><br /><?php 
     ?><center><b>No need for excavation tools here, This bad boy runs!</b></center><br /><?php 
    } 
     elseif ($fight2 > $defensetotal) { 
} 
    else ($rand == 4) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive3,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_43_nm?>'s <img src="<?=$wp_43_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive3?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight2?></b></center><br /></b></center><br /><?php 
    } 
    elseif ($fight2 < $defensetotal) { 
} 
    else ($rand == 4) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake2,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_43_nm?>'s <img src="<?=$wp_43_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake2?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight2?></b></center><br /></b></center><br /><?php 
    } 
      elseif ($fight1 > $defensetotal) { 
} 
    else ($rand == 5) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive2,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_32_nm?>'s <img src="<?=$wp_32_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive2?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight1?></b></center><br /></b></center><br /><?php 
    } 
    elseif ($fight1 < $defensetotal) { 
} 
    else ($rand == 5) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_32_nm?>'s <img src="<?=$wp_32_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake1?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight1?></b></center><br /></b></center><br /><?php 
    } 
    elseif ($rand == 6 || $rand == 7) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$gold1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just got ambushed. You loose 50 gold!</b></center><br /><?php 
    } 
      elseif ($rand == 8 || $rand == 9 || $rand == 10 || $rand == 11 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>After a long hard journey you come up empty handed!</b></center><br /><?php 
    } 
    elseif ($excav1 > $user['uExcavation2']) { 
} 
    else ($rand == 12) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uEleshotbrhinosweap=uEleshotbrhinosweap+$zoidmany,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap6_nm?>. <img src="<?=$mz_weap6_image?>"/>You decide to keep it!</b></center><br /><?php 
    } 
    elseif ($excav2 = $user['uExcavation2']) { 
} 
    else ($rand == 12) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap6_nm?>. <img src="<?=$mz_weap6_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
    ?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 
    } 
     elseif ($fight3 > $defensetotal) { 
} 
    else ($rand == 13) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive4,uWeapon48=uWeapon48+$zoidmany,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_48_nm?>'s <img src="<?=$wp_48_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive4?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>You also managed to take a fully working <?=$wp_48_nm?>, <img src="<?=$wp_48_image?>"/>.</b></center><br /> <?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight3?></b></center><br /></b></center><br /><?php 
    } 
    elseif ($fight3 < $defensetotal) { 
} 
    else ($rand == 13) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake3,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_48_nm?>'s <img src="<?=$wp_48_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake3?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight3?></b></center><br /></b></center><br /><?php 
    } 
     elseif ($rand == 14 || $rand == 15 || $rand == 16 || $rand == 17 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$goldgive1?> Gold. You decide to keep it!</b></center><br /><?php 
    } 
     elseif ($rand == 18 || $rand == 19 || $rand == 20 || $rand == 21 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uMiners=uMiners+$miner,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just found <?=$miner?> miners, your forcing them to join you!</b></center><br /><?php 
    } 
elseif ($turns > $user['uAttackTurns']) { 
} 
    else ($rand == 22) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-$turns,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just lost an additional <?=$turns?>. Better luck next time!</b></center><br /><?php 
    } 

require 'includes/footer.php'; 

?> 

아래의 작업 코드는, 내가 가진 유일한 문제는 구문 오류, 예기치 못한 T_ELSEIF

CODE, 언제 회전 한계를 벗어나면 그들은 계속해서 음전하로 갈 수 있습니다.

<?php 

$ingame = "*"; 
require 'includes/header.php'; 
include 'includes/modzoideditables.php'; 
include 'includes/zoideditables.php'; 
include 'includes/offdefvalues.php'; 
$turns = 5; 
$turns2 = 10; 
$zoidmany = 1; 
$zoidmany2 = 2; 
$excav1 = 1; 
$excav2 = 0; 
$goldgive1 = 500; 
$goldgive2 = 700; 
$goldgive3 = 1000; 
$goldgive4 = 1500; 
$goldgive5 = 2000; 
$fight1 = 20000; 
$fight2 = 27000; 
$fight3 = 31000; 
$goldtake1 = 250; 
$goldtake2 = 500; 
$goldtake3 = 750; 
$goldtake4 = 1000; 
$miner = 5; 
    $rand = rand(1, 22); 
if ($turns > $user['uAttackTurns']) { 
     echo "You don't have enough turns."; 
} 
    $rand = rand(1, 22); 
if ($excav1 > $user['uExcavation2']) { 
} 
    elseif ($rand == 1) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uGatlingzaberfangweap=uGatlingzaberfangweap+$zoidmany,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/>You decide to keep it!</b></center><br /><?php 
    } 
    elseif ($rand == 2) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uGatlingzaberfangweap=uGatlingzaberfangweap+$zoidmany2,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany2?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/>You decide to keep it!</b></center><br /><?php 

     } 
     if ($excav2 = $user['uExcavation2']) { 
} 
    elseif ($rand == 1) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
    ?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 
    } 
    elseif ($rand == 2) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany2?> <?=$mz_weap3_nm?>. <img src="<?=$mz_weap3_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 

    } 
      if ($rand == 3) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uWeapon42=uWeapon42+$zoidmany,uAttackTurns=uAttackTurns+'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>You see something shiny in the distance, What is that you wonder?</b></center><br /><?php 
     ?><center><b>You just found a fully working <?=$wp_42_nm?>!<img src="<?=$wp_42_image?>"/></b></center><br /><?php 
     ?><center><b>No need for excavation tools here, This bad boy runs!</b></center><br /><?php 
    } 
     if ($fight2 > $defensetotal) { 
} 
    elseif ($rand == 4) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive3,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_43_nm?>'s <img src="<?=$wp_43_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive3?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight2?></b></center><br /></b></center><br /><?php 
    } 
    if ($fight2 < $defensetotal) { 
} 
    elseif ($rand == 4) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake2,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_43_nm?>'s <img src="<?=$wp_43_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake2?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight2?></b></center><br /></b></center><br /><?php 
    } 
      if ($fight1 > $defensetotal) { 
} 
    elseif ($rand == 5) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive2,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_32_nm?>'s <img src="<?=$wp_32_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive2?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight1?></b></center><br /></b></center><br /><?php 
    } 
    if ($fight1 < $defensetotal) { 
} 
    elseif ($rand == 5) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_32_nm?>'s <img src="<?=$wp_32_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake1?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight1?></b></center><br /></b></center><br /><?php 
    } 
    if ($rand == 6 || $rand == 7) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$gold1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just got ambushed. You loose 50 gold!</b></center><br /><?php 
    } 
      if ($rand == 8 || $rand == 9 || $rand == 10 || $rand == 11 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>After a long hard journey you come up empty handed!</b></center><br /><?php 
    } 
    if ($excav1 > $user['uExcavation2']) { 
} 
    elseif ($rand == 12) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uEleshotbrhinosweap=uEleshotbrhinosweap+$zoidmany,uExcavation2=uExcavation2-$excav1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap6_nm?>. <img src="<?=$mz_weap6_image?>"/>You decide to keep it!</b></center><br /><?php 
    } 
    if ($excav2 = $user['uExcavation2']) { 
} 
    elseif ($rand == 12) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$zoidmany?> <?=$mz_weap6_nm?>. <img src="<?=$mz_weap6_image?>"/> But you have no excavation tool! You cannot excavate</b></center><br /><?php 
    ?><center><b>Tools needed: 1 <img src="<?=$excav_image2?>"/> </b></center><br /><?php 
    } 
     if ($fight3 > $defensetotal) { 
} 
    elseif ($rand == 13) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive4,uWeapon48=uWeapon48+$zoidmany,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a group of <?=$wp_48_nm?>'s <img src="<?=$wp_48_image?>"/>.</b></center><br /> <?php 
     ?><center><b>You managed to fend them off and scored a nice <?=$goldgive4?> gold!</b></center><br /></b></center><br /><?php 
     ?><center><b>You also managed to take a fully working <?=$wp_48_nm?>, <img src="<?=$wp_48_image?>"/>.</b></center><br /> <?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight3?></b></center><br /></b></center><br /><?php 
    } 
    if ($fight3 < $defensetotal) { 
} 
    elseif ($rand == 13) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold-$goldtake3,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You were attacked by a pack of <?=$wp_48_nm?>'s <img src="<?=$wp_48_image?>"/>.</b></center><br /><?php 
     ?><center><b>Your defense couldn't hold up to their might! You loose <?=$goldtake3?> Gold!</b></center><br /><?php 
     ?><center><b>YOUR DEFENSE: <?=$defensetotal?></b></center><br /></b></center><br /><?php 
     ?><center><b>THEIR ATTACK: <?=$fight3?></b></center><br /></b></center><br /><?php 
    } 
     if ($rand == 14 || $rand == 15 || $rand == 16 || $rand == 17 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET ugold=ugold+$goldgive1,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just stumbled across <?=$goldgive1?> Gold. You decide to keep it!</b></center><br /><?php 
    } 
     if ($rand == 18 || $rand == 19 || $rand == 20 || $rand == 21 ) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uMiners=uMiners+$miner,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just found <?=$miner?> miners, your forcing them to join you!</b></center><br /><?php 
    } 
if ($turns > $user['uAttackTurns']) { 
} 
    elseif ($rand == 22) { 
     $rand_cash = rand(1, 50); 
     $db->query("UPDATE users SET uAttackTurns=uAttackTurns-$turns,uAttackTurns=uAttackTurns-'$turns' WHERE uID='" . $user['uID'] . "'"); 

?><center><b>This Exploration costed you 5 Turns</b></center><br /><?php 
     ?><center><b>You just lost an additional <?=$turns?>. Better luck next time!</b></center><br /><?php 
    } 

require 'includes/footer.php'; 

?> 
+0

줄 번호를 부여합니까? 그건 그걸 추적하려고하는데 도움이 될거야. 또한'else ($ rand == 12) {'는 작동하지 않을 것입니다. 다른 'elseif'가되어야할까요? 코드에는 그 중 몇 가지가 있습니다. – andrewsi

+0

모든 사람들이 문제가 있다고 생각하기 때문에 첫 번째 테스트 코드를 제거하기를 원할 수 있습니다. – Jason

+0

그 코드를 유지해야한다는 것이 다행입니다. 보통 "if elseif"라고 생각하기 시작할 때 더 나은 구조/메소드로 코드를 다시 고려해야합니다. –

답변

0

사용자가 그렇게하는 것을 막는 행위를하지 않기 때문에 사용자가 더 많이 돌아갑니다. 첫 번째 if 문 뒤에 else {}를 사용하여 코드의 나머지 부분을 넣어 : $turns보다 큰$user['uAttackTurns'] 경우이 실행에서 다른 코드를 방지 할 수

if($turns > $user['uAttackTurns']) { 
    echo "You don't have enough turns."; 
} 
else { 

    /*** Carry on As Usual ***/ 
} 

.

또한 $rand = rand(1, 22);을 다시 정의하지 않아도됩니다. 위에서 한 번 선언하고 첫 번째 if 문 다음에 선언합니다.

+0

이것은 실제로 나의 문제를 고쳤다! 정말 고맙습니다. ELSE는 멋진 퍼즐처럼 모든 것을 올바르게 만들어 줄 필요가있었습니다. –

1

무작위 안에있을 갈까요, 당신이

if (condition) 
{ 
//code 
} 
//another code 
elseif (condition) 
{ 
//code 
} 

그래서 당신이 여기에 코드를 변경해야 can'do 없습니다 :

if ($turns > $user['uAttackTurns']) { 
     echo "You don't have enough turns."; 
     $rand = rand(1, 22); 
}  
elseif 
//code... 

편집 :

더있다 다른 이후의 조건이므로

else(condition) 
{ 
//code 
} 

다른 오류가 발생합니다. 다른 모든 것이 실패하면 마지막으로 수행됩니다.

+0

이 작품, 고마워요! –

+0

모든 도움을 주신 분들께 감사 드리며, 나는이 기간 동안 좋은 금액을 배웠습니다. 그것을 고마워한다 –

0

오류는 매우 간결합니다. "예기치 않은 T_ELSEIF"- 어떻게하면 더 간단하게 만들 수 있습니까?

:

가 발생했을 때 선이나 코드를 제공하지 않았다

,하지만 난 그것을 추측하고있어이의 ...이,이 안된다 예상되지 않은 ELSEIF이며, 잘못된 장소에 그래서

if ($turns > $user['uAttackTurns']) { 
     echo "You don't have enough turns."; 
} 
    $rand = rand(1, 22); 
elseif ($excav1 > $user['uExcavation2']) { 
} 
가 다른 하나의 중괄호에서 수행해야, 등, ELSEIF, 다른 할 ...

if (something) 
    { 
    whatever 
    } 
elseif (something else) 
{ 
    whatever else 
} 

을 또한, 나는/ELSEIF 경우 실제로 내부에 $rand VAR를 사용하여 표시되지 않습니다 , 그래서 일부 누락 된 코드가 무엇입니까? if/else 각각에 필요하면 elseif 안에 넣으십시오.

0

첫 번째 'if'와 첫 번째 'elseif'사이에 $rand = rand(1, 22); 문이 있기 때문입니다. 'elseif'는 중간에 명령문이없는 'if'를 직접 따라야합니다.

관련 문제