-2

Hi I'm trying to set certain messages if certain targets aren't met but seems like my If statement wasn't implemented properly can anybody assist please... I would also like to know what should I do to round of my answers so that it don't show any decimals after the comma...

<html>
<body>
<?php

$min = ($_GET["pop"] * 20 / 100);
$max = ($_GET["pop"] * 100 / 20);
?>

You are protected from players with lower than
 <?php if ($min = < 4 ) {echo "Nobody";} else {
echo $min;} ?> pop.<br>
You are protected from players with bigger than 
<?php if ( $max = > 382836 ) {echo "Nobody"} else { echo $max;} ?> pop.

</body>
</html>
  • what is the output on this two if's and what do you expect? – DasSaffe Aug 22 '14 at 15:15
  • 1
    Please use a debugger for this type ("My IF isn't working - why") of question. See [this](http://stackoverflow.com/questions/888/how-do-you-debug-php-scripts) question for help. – Hirnhamster Aug 22 '14 at 15:16

3 Answers3

4

I think you're using the wrong comparison operators (those operators aren't defined in PHP, or any language that I know of for that matter!). You need $min <= 4, not $min = < 4. Similar you need $max >= 382846, not $max = > 382836.

There's also a semi-colon missing on one of your lines (should be {echo "Nobody";} with a semi-colon at the end).

Warren Moore
  • 448
  • 3
  • 12
0

use of operator is incorrect. = <should be <= and = > should be >= . Try this

<?php 
if ($min <= 4 ) {
    echo "Nobody";
} else {
    echo $min;
} ?>

<?php 
if ( $max >= 382836 ) {
    echo "Nobody";
} else {  
   echo $max;
} ?>
MH2K9
  • 11,951
  • 7
  • 32
  • 49
0

You mixed the compare-operators. It has to be >= or <=

if($min <= 4) { 
    echo "Nobody";
}
else {
    echo $min;
}

and of course the other if-statement:

if($max >= 382836) {
    echo "Nobody";
}
else {
    echo $max;
}
DasSaffe
  • 2,080
  • 1
  • 28
  • 67