Jump to content

getting T_VARIABLE error.


seany123

Recommended Posts

im getting this error: Parse error: parse error, unexpected T_VARIABLE in xxxx/xxxx/xxxxxxx on line 27.

 

This is the code.

 

<?
include ("lib.php");
if ($_GET['act'] == "1" && $player->nerve > 0)
{
if($perc2 > 74 && $crime < 9) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player
	 echo "You gained 25 EXP and $10";
	 $query = $db->execute("update `players` set `exp`=?, `money`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->money + 10, $player->nerve - 1, $player->id));
}
}
else if($crime > 8 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1, $player->id));
}
else if($crime > 
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));

}
else
{
if($perc2 > 48 && $perc2 < 75 $crime < 7) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 6 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 6)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}
else
{
if($perc2 > 24 && $perc2 < 49 && $crime < 5) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 4 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 4)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}
else
{
if($perc2 > 0 && $perc2 < 25 && $crime < 3) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 2 && $jail < 3)
{
//Update player
	 echo = "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 2)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}


else
{
echo "Not enough Nerve";
}
?>

 

whats wrong with the code?

Link to comment
Share on other sites

I can see that maybe there too much in the code for you to really see any errors, so i have stripped the code down completely:

 

<?
if ($_GET['act'] == "1" && $player->nerve > 0)
{
if($perc2 > 74 && $crime < 9) 
{

}
else if($crime > 8 && $jail < 3)
{

}
else if($crime > 
{

}
else
{
if($perc2 > 48 && $perc2 < 75 $crime < 7) 
{

}
else if($crime > 6 && $jail < 3)
{

}
else if($crime > 6)
{

}
else
{
if($perc2 > 24 && $perc2 < 49 && $crime < 5) 
{

}
else if($crime > 4 && $jail < 3)
{

}
else if($crime > 4)
{

}
else
{
if($perc2 > 0 && $perc2 < 25 && $crime < 3) 
{

}
else if($crime > 2 && $jail < 3)
{

}
else if($crime > 2)
{

}
}
else
{
echo "Not enough Nerve";
}
?>

 

still getting same T_VARIABLE error on line 18.

Link to comment
Share on other sites

great thing about indenting is it's easier to tell when things go awry.  Assuming this is how you really want your conditions structured:

<?
if ($_GET['act'] == "1" && $player->nerve > 0){
  if($perc2 > 74 && $crime < 9){
  } else if($crime > 8 && $jail < 3) {
  } else if($crime >  {
  } else {
     if($perc2 > 48 && $perc2 < 75 $crime < 7) {
     } else if($crime > 6 && $jail < 3) {
     } else if($crime > 6) {
     } else {
       if($perc2 > 24 && $perc2 < 49 && $crime < 5) {
       } else if($crime > 4 && $jail < 3){
       } else if($crime > 4) {
       } else {
          if($perc2 > 0 && $perc2 < 25 && $crime < 3) {
          } else if($crime > 2 && $jail < 3) {
          } else if($crime > 2) {
          } // problem starts here
       } else {
          echo "Not enough Nerve";
       }
?>

 

You know I'm actually looking at the conditions themselves and I strongly advise you sit down and rethink what it is you're trying to do.

Link to comment
Share on other sites

oh right.

 

well to be honest, i know its easier to read, but other than that there is no other reason for me to indent my codes.

 

yeah i am lazy but i get through a lot of codes and it isn't really worth keeping having to make it look good.

 

 

Can anyone help me with why im getting this error?

 

Link to comment
Share on other sites

yes fixed the &&.

 

getting T_ELSE error on line 29.

 

<?
include ("lib.php");
if ($_GET['act'] == "1" && $player->nerve > 0)
{
if($perc2 > 74 && $crime < 9) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player
	 echo "You gained 25 EXP and $10";
	 $query = $db->execute("update `players` set `exp`=?, `money`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->money + 10, $player->nerve - 1, $player->id));
}
}
else if($crime > 8 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1, $player->id));
}
else if($crime > 
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));

}
else
{
else if($perc2 > 48 && $perc2 < 75 || $crime < 7) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 6 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 6)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}
else
{
if($perc2 > 24 && $perc2 < 49 || $crime < 5) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 4 && $jail < 3)
{
//Update player
	 echo "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 4)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}
else
{
if($perc2 > 0 && $perc2 < 25 || $crime < 3) 
{
if (25 + $player->exp >= $player->maxexp) //Player gained a level!
    {
     //Update player, gained a level
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `points`=?, `level`=?, `maxexp`=?, `maxhp`=?, `exp`=?, `money`=?, `hp`=?, `nerve`=? where `id`=?", array($player->points + 3, $player->level + 1, ($player->level+1) * 70 - 20, $player->maxhp + 30, $player->money + 10, $newexp, $player->nerve - 1, $player->id));
}
else
     //Update player
	 echo "You gained 25 EXP"
	 $query = $db->execute("update `players` set `exp`=?, `nerve`=? where `id`=?", array($player->exp + 25, $player->nerve - 1, $player->id));
}
}
else if($crime > 2 && $jail < 3)
{
//Update player
	 echo = "You Failed the Crime and was sent to Prison!";
	 $query = $db->execute("update `players` set `nerve`=?, `prison`=?  where `id`=?", array($player->nerve - 1, $player->prison + 1 $player->id));
}
else if($crime > 2)
{
//Update player
	 echo "You Failed the Crime!";
	 $query = $db->execute("update `players` set `nerve`=? where `id`=?", array($player->nerve - 1, $player->id));
}


else
{
echo "Not enough Nerve";
}
?>

 

 

Link to comment
Share on other sites

Dude, the answers have already been given to you, several times.  Go back and look at the posted codes, from any number of people.  You get one thing fixed and the same exact error shows up a few lines later.  What does that tell you?  Because posting the same error for a few lines down just tells us you're too lazy to read what's being posted or fix it yourself.

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.