MakeWebGames

# Quick coding question

## Recommended Posts

I was going through my crappy coding, obviously done by me and i saw this:

if(\$ir['fedjail'] > 0)

{

print "No attacking people who can't attack back...TUT TUT!";

\$h->endpage();

exit;

}

I was just wondering, seeing as that doesnt work, how do you do if it does NOT equal 0? Example:

if(\$ir['fedjail'] (stuff for does not)= 0)

{

print "No attacking people who can't attack back...TUT TUT!";

\$h->endpage();

exit;

}

so it's saying if fedjail does NOT equal 0, you can't attack them, if it is 0, you can.

##### Share on other sites

Re: Quick coding question

Use !=

eg.

```
if(\$ir['fedjail'] != 0)
{
print "No attacking people who can't attack back...TUT TUT!";
\$h->endpage();
exit;
}
```
##### Share on other sites

Re: Quick coding question

Use !=

eg.

```
if(\$ir['fedjail'] != 0)
{
print "No attacking people who can't attack back...TUT TUT!";
\$h->endpage();
exit;
}
```

Hmm can still attack people in fed. Does the != mean the negative of the normal stuff?

##### Share on other sites

Re: Quick coding question

Use !=

eg.

```
if(\$ir['fedjail'] != 0)
{
print "No attacking people who can't attack back...TUT TUT!";
\$h->endpage();
exit;
}
```

Hmm can still attack people in fed. Does the != mean the negative of the normal stuff?

Have a look at the operators.

##### Share on other sites

Re: Quick coding question

this is the same problem..your using \$ir that mean you...your wanting to check the other person and in the attack.php thats \$odata

So use this.

```
if(\$odata['fedjail'] != 0)
{
print "No attacking people who can't attack back...TUT TUT!";
\$h->endpage();
exit;
}

```
##### Share on other sites

Re: Quick coding question

beat me to it alabama .... lol

##### Share on other sites

Re: Quick coding question

if(!empty(\$odata['fedjail)) {

##### Share on other sites

Re: Quick coding question

oh dear

##### Share on other sites

Re: Quick coding question

wouldn't

```if(!empty(\$odata['fedjail))
```

be

not empty which basically means it contains something besides null

...

##### Share on other sites

Re: Quick coding question

the default value would be null though...

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.