Jump to content

Recommended Posts

I get this error:

Parse error: syntax error, unexpected T_IF in /home/darktime/public_html/item-action.php on line 471

 

The first line is 471

with this code:

 

if ($action == 9) {

      if (empty($hidden)) {

      $status = "

        <form action=\"$PHP_SELF?iid=$tid\" method=\"post\">

         <input type=\"hidden\" name=\"hidden\" value=\"1\">

         <input type=\"hidden\" name=\"action\" value=\"9\">
<br>
         Use On :: <input type=\"text\" name=\"uname\" maxlength=\"20\" style=\"width: 150px\">

         <br><br>

         <input type=\"submit\" value=\"Attack\">

      ";

    } else { 

      $check = mysql_query("SELECT * FROM members WHERE username = '$uname'") or die(mysql_error());

      $checknum = mysql_num_rows($check);
      $check = mysql_fetch_object($check);

  
  
      if (!$uname) {

        $status = "

          Please fill in the username.

          <br><br>

          <input type=submit value=\"Go Back\" onClick=\"history.go(-1)\">

        ";

      } elseif ($checknum == 0) {

        $status = "

          User \"$uname\" does not exsist.

          <br><br>

          <input type=submit value=\"Go Back\" onClick=\"history.go(-1)\">

        ";

      }
      $hitself = rand(1,10)
      if($hitself <= 2){$attack = 2;}
      else{$attack = 1;}
       if(!empty($check->shield)){
  $itemshield = mysql_query("SELECT * FROM inventory WHERE tid = '$check->shield'") or die(mysql_error());

  $itemshield = mysql_fetch_object($itemshield);
  
  if($itemshield->iid == 220){
  $shield = 1;
    }
  else{$shield = 0; $attack = 1;} }
  if($shield = 1){
  $chance = rand(1,10)
  if($chance >= 6){$attack = 0;}
  elseif($chance <= 3){$attack = 2;}
  else{$attack = 1;}
   
  }
      
      if($attack = 0){
      $status = "This users Shield Cloak worked and you didn't hurt them (The chances are random and you can hurt them sometimes, but be careful it can also backfire!)<br><input type=\"button\" value=\"Back\" onClick=\"location.href='inventory.php'; return true;\">"
      
      
      }
      elseif($attack = 2){
      $newhealth = rand($iteminfo->mindamage, $iteminfo->maxdamage);
$damage = $newhealth;
$newhealth = user($username, health) - $newhealth;
if($newhealth < 0){$newhealth = '0';};
        mysql_query("UPDATE members SET health = '$newhealth' WHERE username = '$username'") or die(mysql_error());
  $event = "Your attack backfired and you hit yourself for $damage points of damage!";
$event= str_replace("'","\'",$event);
        mysql_query("INSERT INTO events SET username = '$uname', event = '$event'") or die(mysql_error());
    if($iteminfo->reuse == 0){  mysql_query("DELETE FROM inventory WHERE tid = '$tid'") or die(mysql_error());
        };$status = "

          Your attack backfired and you hit yourself for $damage points of damage!

          <br><br>

          <input type=\"button\" value=\"Back\" onClick=\"location.href='inventory.php'; return true;\">";
      
      
      
      }
      
      elseif ($shield = 0 || $attack = 1)     	
       {     
       $newhealth = rand($iteminfo->mindamage, $iteminfo->maxdamage);
$damage = $newhealth;
$newhealth = user($uname, health) - $newhealth;
if($newhealth < 0){$newhealth = '0';};
        mysql_query("UPDATE members SET health = '$newhealth' WHERE username = '$uname'") or die(mysql_error());
  $event = "$username attacked you with $name for $damage points of damage!";
$event= str_replace("'","\'",$event);
        mysql_query("INSERT INTO events SET username = '$uname', event = '$event'") or die(mysql_error());
    if($iteminfo->reuse == 0){  mysql_query("DELETE FROM inventory WHERE tid = '$tid'") or die(mysql_error());
        };$status = "

          Attacked $uname for $damage points of damage!

          <br><br>

          <input type=\"button\" value=\"Back\" onClick=\"location.href='inventory.php'; return true;\">

        ";

      }

    }

  }

Link to comment
https://forums.phpfreaks.com/topic/56564-help/
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.