PDA

View Full Version : Checking two statments



epic1231
Feb 6th, 2010, 08:13 PM
Hey everyone, have a very simple issue that for some reason I can't seem to come up with the correct if statement for.

I have a game, when a user is placed on a list they will not be able to use some of the functions in the game, one of them being the Hospital.

I am trying to use this code, the $user comes from a table called users, the $row[hitUserid], comes from another table called list.

What I would like it to show is if the user is on the list then they can not heal right now.. If they are not on the list then they can heal or if their health is full it says the else command at the bottom..

Any suggestions to why it's not working?

Thanks!



$pirate = Pirate::getById($user);

if ($user == $row[hitUserid]) {
echo '<div id="reply" style="background-color:#ffffff; width:500px; Height:25px; padding:2px; border: solid #cccccc 3px;">can not heal right now</div>';
}
else if ($pirate->health < $pirate->maxhealth) {

echo '<div id="reply" style="background-color:#ffffff; width:500px; Height:25px; padding:2px; border: solid #cccccc 3px;"><a Onclick="hospital(\'reply\'); return false;">Heal your character for $';
$valore = ($pirate->maxhealth - $pirate->health) * 5 * $pirate->level;
echo $valore; echo '</a></div>';


} else { echo '<P class="bigWhiteP">You are now at full health!</P>';}

mlseim
Feb 6th, 2010, 08:40 PM
I'm not sure if having single quotes on the variable name makes a difference or not ...

$row['hitUserid']

tomws
Feb 6th, 2010, 11:18 PM
mlseim, PHP still works with the incorrect syntax, but it's accidental and unsupported behavior. It's on this manual page (http://php.net/manual/en/language.types.array.php) under the section "Why is $foo[bar] wrong?".

To the OP, which case is actually failing to work like you expect? Your post seems ambiguous.