Jump to content


Photo

Help me please (again)


  • Please log in to reply
11 replies to this topic

#1 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 09:13 AM

(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

<?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>
<?

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


#2 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 09:39 AM

Anyone?

#3 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 12 October 2006 - 09:51 AM

could you try putting the } before the else near the bottom? if it dont work i'll read it a bit better. :P
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#4 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 09:59 AM

Hey thanks for your reply project

But that didn't solve my problem. :(

#5 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 11:02 AM

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.

#6 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 October 2006 - 11:07 AM

You're missing a closing "}" on this "if" statement:
<?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{ ?>

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

Ken

#7 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 11:12 AM

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

<?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>


#8 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 11:17 AM

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

Try this:

<?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>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#9 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 12:28 PM

That fixed the error but now it dont update the database with the $rand_Gems

#10 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 12:31 PM

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

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

Inside here:
<?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).";
}
?>

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

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#11 R1der

R1der
  • Members
  • PipPipPip
  • Advanced Member
  • 104 posts

Posted 12 October 2006 - 12:34 PM

That worked. wow so simple :P

Thanks again :)

#12 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 12 October 2006 - 12:35 PM

Anytime my friend :)

Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users