0

Hi!

I have a problem with the following statement:

$dbres				= mysql_query("SELECT UNIX_TIMESTAMP(`huur`) AS `huur`,huur1,`login`,UNIX_TIMESTAMP(`signup`) AS `signup`,`attack`,`defence`,`clicks`,`attlosses`,`attwins`,`deflosses`,`defwins`,`cash`,`type`,`clan`,'maffiamode',`avaurl` FROM `[users]` WHERE `login`='{$_GET['x']}'");
    if($def = mysql_fetch_object($dbres)) {
      if($def->login == $data->login){
	    print "  <tr><td class=\"mainTxt\">You kicked yourself in the nuts... now what?.</td></tr>\n";
      }else if($def->login == $admin1)
        print "  <tr><td class=\"mainTxt\">Do NOT attack an admin!</td></tr>\n";
else if($def->maffiamode == 1)
        print "  <tr><td class=\"mainTxt\">This pirate is currently under Davy Jones' protection!!</td></tr>\n";}
      else {

Even when $def->maffiamode == 1
really is set to 1 in the database

it still doesn't display the message...

The first 2 statements (

if($def->login == $data->login){

and

}else if($def->login == $admin1)

work without a problem

need any further info?
(I attached the file so you can see for yourself)

Attachments
<?php /* ------------------------- */

  include("_include-config.php");
    include("_include-gevangenis.php");
  if(! check_login()) {
    header("Location: login.php");
    exit;
  }

 $code = rand(1,111333777);

/* ------------------------- */ ?>
<html>


<head>
<title></title>
</head>
<link rel="stylesheet" type="text/css" href="<? echo $sitelink;?>/layout/layout<?php echo $page->layout; ?>/css/css.css">
<table width=100%>
  <tr><td class="subTitle"><b>Attack</b></td></tr>
<?php /* ------------------------- */

	$boksen1           = mysql_query("SELECT *,UNIX_TIMESTAMP(`werken`) AS `werken`,0 FROM `[users]` WHERE `login`='$data->login'");
	$boksen            = mysql_fetch_object($boksen1);
	$tijdverschil1        = $boksen->werken-time() - 12500;
    $tijdverschil        = date("i:s", "$tijdverschil1");
	if($boksen->werken + $boksen->werken1 > time()){
	print "<tr><td class=\"mainTxt\" align=\"center\">You can $tijdverschil seconds at work</td></tr>";
	}
	elseif(round($data->signup/3600-time()/3600) + 12 <= 0) {
    $dbres				= mysql_query("SELECT UNIX_TIMESTAMP(`huur`) AS `huur`,huur1,`login`,UNIX_TIMESTAMP(`signup`) AS `signup`,`attack`,`defence`,`clicks`,`attlosses`,`attwins`,`deflosses`,`defwins`,`cash`,`type`,`clan`,'maffiamode',`avaurl` FROM `[users]` WHERE `login`='{$_GET['x']}'");
    if($def = mysql_fetch_object($dbres)) {
      if($def->login == $data->login){
	    print "  <tr><td class=\"mainTxt\">You kicked yourself in the nuts... now what?.</td></tr>\n";
      }else if($def->login == $admin1)
        print "  <tr><td class=\"mainTxt\">Do NOT attack an admin!</td></tr>\n";
else if($def->maffiamode == 1)
        print "  <tr><td class=\"mainTxt\">This pirate is currently under Davy Jones' protection!!</td></tr>\n";}
      else {
        $dbres				= mysql_query("SELECT * FROM `[logs]` WHERE `login`='{$data->login}' AND `person`='{$def->login}' AND FLOOR(UNIX_TIMESTAMP(`time`)/(60*60*24))=FLOOR(UNIX_TIMESTAMP(NOW())/(60*60*24)) AND `area`='attack'");
        if(($numattacks = mysql_num_rows($dbres)+1) <= 99999999999999999999999999999999999) {
          $dbres			= mysql_query("SELECT * FROM `[logs]` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`time`) < -1 AND `login`='{$data->login}' AND `area`='attack'");
          if(mysql_num_rows($dbres) == 0) {
            mysql_query("SELECT GET_LOCK('attack_{$def->login}',25)");
            $result			= (($data->attack+$data->clicks*5)*rand(90,115) >= ($def->defence+$def->clicks*5)*rand(90,115)) ? 1 : 0;
            $money			= ($result == 1) ? (int)($def->cash*rand(40,75)/100) : (int)($data->cash*rand(25,40)/100);
            $text			= ($result == 1) ? Array("You won!","gewonnen") : Array("You lost.","verloren");
    if($money < 0){
echo '<table width=100%><tr><td class=Maintxt>He grabs you by the throat!<br />you are so scared you crapped your pantaloons..<br /><br />but he leaves you alone';
exit;
}

print <<<ENDHTML

<table align=center width=100%>
  <tr>
    <td class="subTitle">{$data->login}</td>
    <td class="subTitle">Against</td>
    <td class="subTitle">{$def->login}</td>
  </tr>
  <tr>
    <td class="mainTxt"><center><img border="0" src="{$data->avaurl}" width="231" height="221"></center></td>
    <td class="mainTxt">Against</td>
    <td class="mainTxt"><center><img border="0" src="{$def->avaurl}" width="231" height="221"></center></td>
  </tr>
</table>
ENDHTML;

            $forwardedFor		= ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'];
            $forwardedFor		= preg_replace('/, .+/','',$forwardedFor);
            mysql_query("INSERT INTO `[logs]`(`time`,`IP`,`forwardedFor`,`login`,`person`,`code`,`area`) values(NOW(),'{$_SERVER['REMOTE_ADDR']}','$forwardedFor','{$data->login}','{$def->login}',($money << 1) | $result,'attack')");
            if($result == 1) {
              mysql_query("UPDATE `[users]` SET `cash`=". ($def->cash-$money) .",`deflosses`=". ($def->deflosses+1) ." WHERE `login`='{$def->login}'");
              $data->cash		+= $money;
              $data->attwins++;
              mysql_query("UPDATE `[users]` SET `cash`={$data->cash},`attwins`={$data->attwins} WHERE `login`='{$data->login}'");
            }
            else {
              $data->cash		-= $money;
              $data->attlosses++;
              mysql_query("UPDATE `[users]` SET `cash`={$data->cash},`attlosses`={$data->attlosses} WHERE `login`='{$data->login}'");
              mysql_query("UPDATE `[users]` SET `cash`=". ($def->cash+$money) .",`defwins`=". ($def->defwins+1) ." WHERE `login`='{$def->login}'");
            }

    print <<<ENDHTML
<html>


<head>
<title></title>


</head>

  <table width=100%>
    <tr><td class="mainTxt">
	<center>You attack {$def->login} and... {$text[0]}<br>You got $money {$text[1]}...</td></tr>\n
	</center>
    </td></tr>
  </table>
</body>

</html>
ENDHTML;
            mysql_query("SELECT RELEASE_LOCK('attack_{$def->login}')");
          }
          else {
            $type			= Array("","junkies","klonen","agenten","Terroristen","Gangsters");
            $type			= $type[$data->type];
            $avatar		= $avatar[$data->avatar];
            print "  <tr><td class=\"mainTxt\">Your $type are still tired from last attack...</td></tr>\n";
          }
        }
        else
          print "  <tr><td class=\"mainTxt\">You already attacked {$def->login} 5x last hour...</td></tr>\n";
      }
    }
  else
    print "  <tr><td class=\"mainTxt\">Je kunt niemand aanvallen wanneer je onder bescherming staat</td></tr>\n";

/* ------------------------- */ ?>

</table>

</body>
</html><table width=100%>
<tr><td class=Maintxt>
<a href="javascript:history.go(-1)"> Back</a>
</tr></td>
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by chrishea
0

You don't have a closing bracket before the else if on line 7. This doesn't result in an error in the interpreter but I think it is causing it to skip over the else if and go directly to the else on line 9 every time the initial if isn't satisfied.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.