Results 1 to 2 of 2

Thread: PHP help

  1. #1
    Join Date
    Aug 2005
    Posts
    1

    PHP help

    Hello i am learning php just now and am using a training course to learn.But i have a problem am trying to use the && but can't get it to work.
    This is the code it say to use:

    if (($a > 100) && ($a <2000)) {
    echo "number is greater than 100 but less than 2000";
    }

    i have tried moving the $a values up and down but just can't get this to work.
    Please help me out.

    if i don't get it soon i will have no hair left at al

  2. #2
    Join Date
    May 2005
    Location
    Ohio
    Posts
    32
    What's the whole script that you are using? The reason I ask, is to me, this works fine.

    Make sure $a has been assigned a value.

    I used:
    PHP Code:
    $a 101;
     if ((
    $a 100) && ($a <2000)) {
       echo 
    "Number is greater than 100 but less than 2000 ($a)";
     } else {
       echo 
    "The value of \$a is $a";
     } 
    and everything worked fine, I got the original output.

    What do you get if you use an else like I did above with a different set of output?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •