Jump to content

Help me please (again)


R1der

Recommended Posts

(Hey Hey i am back again but one of my mess ups lol) ok i am getting this error
Parse error: parse error, unexpected T_ELSE in /home/fhlinux202/h/hcn-chat.com/user/htdocs/game/play/mine2.php on line 27

[code]<?php
if(!$_GET['stp']){
?>
<b>You walk into the mine and see loads of rocks..<br>

<a href="mine2.php?stp=bronze">Mine with bronze pickaxe</a><br>

<?php
}
elseif($_GET['stp'] == "bronze"){
if($user['uAttackTurns'] <= 4){
echo "You Dont have enough Energy to mine.";
exit;}
if($user['uPickaxe']=='0'){
echo "You need a pickaxe to mine gems.";
exit;}
$rand = rand(1,20);
if($rand==1 || $rand==5 || $rand==10 || $rand==15 || $rand==20 || $rand==25) {

$rand_gems = rand(1,5);

echo "You start to mine with your bronze pickaxe and find $rand_gems gem(s).";
else{
echo "You find nothing but bits of useless rock";

$db->query("UPDATE users SET uGems=uGems+'$rand_gems' WHERE uID='" . $user['uID'] . "'");
}
}
?>
<a href="mine2.php?stp=bronze"><br>Mine again</a><br>
<?[/code]

Now personaly i dont see a problem in the else statement and i been trying to sort it now for almost a hour.

Thanks in advance
Link to comment
Share on other sites

You're missing a closing "}" on this "if" statement:
[code]<?php
if($rand==1 || $rand==5 || $rand==10 || $rand==15 || $rand==20 || $rand==25) {

$rand_gems = rand(1,5);

echo "You start to mine with your bronze pickaxe and find $rand_gems gem(s).";
} // <--- insert this missing closing curly bracket
else{ ?>[/code]

If you indent your code correctly this would have been very apparent.

Ken
Link to comment
Share on other sites

I still get the same error. Parse error: parse error, unexpected T_ELSE in /home/fhlinux202/h/hcn-chat.com/user/htdocs/game/play/mine2.php on line 27

[code]<?php
if(!$_GET['stp']){
?>
<b>You walk into the mine and see loads of rocks..<br>

<a href="mine2.php?stp=bronze">Mine with bronze pickaxe</a><br>

<?php
}
elseif($_GET['stp'] == "bronze"){
if($user['uAttackTurns'] <= 4){
echo "You Dont have enough Energy to mine.";
exit;}
if($user['uPickaxe']=='0'){
echo "You need a pickaxe to mine gems.";
exit;}
$rand = rand(1,20);
if($rand==1 || $rand==5 || $rand==10 || $rand==15 || $rand==20 || $rand==25) {

$rand_gems = rand(1,5);

echo "You start to mine with your bronze pickaxe and find $rand_gems gem(s).";
else{
echo "You find nothing but bits of useless rock";
}
$db->query("UPDATE users SET uGems=uGems+'$rand_gems' WHERE uID='" . $user['uID'] . "'");
}
}
?>
<a href="mine2.php?stp=bronze"><br>Mine again</a><br>[/code]
Link to comment
Share on other sites

You still haven't pasted in the closing curley brace!

Try this:

[code]<?php
if(!$_GET['stp']){
?>
<b>You walk into the mine and see loads of rocks..<br>

<a href="mine2.php?stp=bronze">Mine with bronze pickaxe</a><br>

<?php
}
elseif($_GET['stp'] == "bronze"){
  if($user['uAttackTurns'] <= 4){
      echo "You Dont have enough Energy to mine.";
      exit;
  }
  if($user['uPickaxe']=='0'){
      echo "You need a pickaxe to mine gems.";
      exit;
  }
  $rand = rand(1,20);
  if($rand==1 || $rand==5 || $rand==10 || $rand==15 || $rand==20 || $rand==25){
      $rand_gems = rand(1,5);
      echo "You start to mine with your bronze pickaxe and find $rand_gems gem(s).";
  }
  else{
      echo "You find nothing but bits of useless rock";
      $db->query("UPDATE users SET uGems=uGems+'$rand_gems' WHERE uID='" . $user['uID'] . "'");
  }
}
?>
<a href="mine2.php?stp=bronze"><br>Mine again</a><br>[/code]

Regards
Huggie
Link to comment
Share on other sites

It won't, you have your code in the wrong place...

Move this:
[code=php:0]$db->query("UPDATE users SET uGems=uGems+'$rand_gems' WHERE uID='" . $user['uID'] . "'");
[/code]

Inside here:
[code]
<?php
if($rand==1 || $rand==5 || $rand==10 || $rand==15 || $rand==20 || $rand==25){
      $rand_gems = rand(1,5);
      echo "You start to mine with your bronze pickaxe and find $rand_gems gem(s).";
}
?>
[/code]

You currently have it updating the database if they don't find the gems, not if they do :)

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