Jump to content

Got a problem - trying to get this to work right!


canadian_angel

Recommended Posts

I have to use an if statement to print the string youth message to a browser if an integer variable $age is between 18-35 and if age contains any other value the string generic message displays-so far i got this and both messages display ugh!       

 

 

 

<?php

       

        // Address error handling.

        ini_set ('display_errors', 1);

        error_reporting (E_ALL & ~E_NOTICE);

// Validate the age.

   

        if ('$age = 18 - 35') {

        print '<p>Youth Message!</p>';

        } else {

            $age .=$age;

        } // End of  1st conditional.

 

      if ('$age => 35') {

        print '<p>Generic Message!</p>';

        } else {

            $age .=$age;

        } // End of  2nd conditional.

       

   

        ?>

Try this

<?php

// Address error handling.
        ini_set ('display_errors', 1);
        error_reporting (E_ALL & ~E_NOTICE);
// Validate the age.
     
        if ($age >= 18 || $age < 35) { // Here is the change, but it may be if($age >= 18 && $age < 35)
        print '<p>Youth Message!</p>';
        } else {
            $age .=$age;
        } // End of  1st conditional.

       if ($age >= 35) {
        print '<p>Generic Message!</p>';
        } else {
            $age .=$age;
        } // End of  2nd conditional.
       
     
        ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.