Jump to content

Archived

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

R1der

Help me please (again)

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

Share this post


Link to post
Share on other sites
could you try putting the } before the else near the bottom? if it dont work i'll read it a bit better. :P

Share this post


Link to post
Share on other sites
Hey thanks for your reply project

But that didn't solve my problem. :(

Share this post


Link to post
Share on other sites
Guys i really need help here. i need this script to go live today. and i have more coding to add to it. :-\

Sorry to stress but this is kinda important.

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
That fixed the error but now it dont update the database with the $rand_Gems

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.