Trouble with PHP "IF" Statement

[code]
<?
$success = 0;
$botch = 0;
for($i=0; $i<$TOTALDICE; $i++)
{
$dicearray[$i] = (rand()%10)+1;
if($dicearray[$i] >= $DIFF){
$success++;
$botch++;
}
if($dicearray[$i] <= 1){
$success--;
}
echo $dicearray[$i];
if($i+1 != $TOTALDICE)
{
echo ", ";
}
}
if ($WP="yes"){
$success++;
$botch++;
}
echo " You rolled $TOTALDICE Dice at Difficulty $DIFF to $ACTION and ";
if($success <= 0 && $botch > 0){
echo " You have FAILED ! !";
}
else if($success <= 0 && $botch <= 0){
echo " You have BOTCHED ! !";
}
else{
echo " You have $success successes ! !";
}
if ($WP="yes"){
echo " You have used 1 Willpower !";
}
?>
[/code]

I created this code on a website form, with the text box ACTION, List box DIFF, text box TOTALDICE and list box WP. the code works great except the WP portion. It keeps adding the WP without paying attention to the "IF" statement. Can anyone help me out here, I am very new to PHP, I would prefer to set a check box and use a boolean variable, but not sure how to do that yet. Thank you.

the darthmoob

Comments

  • : [code]
    :
    : if ($WP [red]=[/red]= "yes"){
    : $success++;
    : $botch++;
    : }
    : echo " You rolled $TOTALDICE Dice at Difficulty $DIFF to $ACTION and ";
    : if($success <= 0 && $botch > 0){
    : echo " You have FAILED ! !";
    : }
    : else if($success <= 0 && $botch <= 0){
    : echo " You have BOTCHED ! !";
    : }
    : else{
    : echo " You have $success successes ! !";
    : }
    : if ($WP [red]=[/red]= "yes"){
    : echo " You have used 1 Willpower !";
    : }
    : ?>
    : [/code]
    :
    : I created this code on a website form, with the text box ACTION, List box DIFF, text box TOTALDICE and list box WP. the code works great except the WP portion. It keeps adding the WP without paying attention to the "IF" statement. Can anyone help me out here, I am very new to PHP, I would prefer to set a check box and use a boolean variable, but not sure how to do that yet. Thank you.
    :
    == is the equality testing operator. The = operator is for assignment, and thus you are testing if a true value was assigned. Certain languages (e.g. BASIC) use the same operator for these (though it's not a good idea to do that really).

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : [code]
    : :
    : : if ($WP [red]=[/red]= "yes"){
    : : $success++;
    : : $botch++;
    : : }
    : : echo " You rolled $TOTALDICE Dice at Difficulty $DIFF to $ACTION and ";
    : : if($success <= 0 && $botch > 0){
    : : echo " You have FAILED ! !";
    : : }
    : : else if($success <= 0 && $botch <= 0){
    : : echo " You have BOTCHED ! !";
    : : }
    : : else{
    : : echo " You have $success successes ! !";
    : : }
    : : if ($WP [red]=[/red]= "yes"){
    : : echo " You have used 1 Willpower !";
    : : }
    : : ?>
    : : [/code]
    : :
    : : I created this code on a website form, with the text box ACTION, List box DIFF, text box TOTALDICE and list box WP. the code works great except the WP portion. It keeps adding the WP without paying attention to the "IF" statement. Can anyone help me out here, I am very new to PHP, I would prefer to set a check box and use a boolean variable, but not sure how to do that yet. Thank you.
    : :
    : == is the equality testing operator. The = operator is for assignment, and thus you are testing if a true value was assigned. Certain languages (e.g. BASIC) use the same operator for these (though it's not a good idea to do that really).
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :
    Thanks Jonathan, it worked great. I Was wondering another quick question, I have the page and everytime it loads now, it automatically says "you have failed no successes" obviously because there has been no roll on the Dice Roller. Is there a way for me to initialize the php code to run only when the submit button is pressed, like maybe setting the action of the form to a function instead of the entire php page? And second, is there a way for me to "Array" the rolls done by the Dice Roller on a webpage, to show the "Latest" 10 rolls or so, by anyone. So for example if I were to open the dice roller page, I could see the last 10 rolls anyone made on there. Then if I make a roll, it would become the latest roll, and everyone else could see mine? I appreciate anyones help with this, I am a bit stumbled mainly on the array portion of the coding.

    the darthmoob
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories