Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:18:41+00:00 2026-05-29T09:18:41+00:00

This is really bothering me. I’m having trouble with some very very simple logic.

  • 0

This is really bothering me. I’m having trouble with some very very simple logic. A variable has to be between 5 and 35. If it is I want to print pass, if not print fail. I can’t, for the life of me, get this to work. Its so simple…

    if($turboPressure > 5 && $turboPressure < 35) 
    {print "pass";}
    else
    {print "fail";}

Thats my latest attempt… I’ve tried like 4 different conditions and none have worked… Please help.

If anyone would like to look at it, I think you can view it at…
http://www.deltacst.net/php06/Lab4/Lab4.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:18:43+00:00Added an answer on May 29, 2026 at 9:18 am

    Your code works fine. Here’s proof:

    foreach( range( 0, 40) as $turboPressure)
    {
        echo $turboPressure . ' ';
        echo (($turboPressure > 5 && $turboPressure < 35) ? 'pass' : 'fail');
        echo "\n";
    }
    

    This loops through 0 to 40, printing either pass or fail with the same condition you wrote.

    You might want to do:

    $turboPressure = intval( $turboPressure); 
    

    This makes sure that you’re dealing with integers instead of strings. If you’re using strings, your comparison will fail.

    The only tricky part of my sample is the ternary operator, which takes this:

    if( condition)
        $var = 'something1';
    else
        $var = 'something2';
    

    And transforms it into

    $var = (condition) ? 'something1' : 'something2';
    

    Watch it work.

    Edit:

    Based on your sample code, you should get $turboPressure like so:

     $turboPressure = intval( $_POST['turboPressure']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This really has my stumped today. I'm sure its simple, but... Here is my
I've been having this really annoying thing happen the past few days, that has
This has been bothering me a while... and it's really hard to really see
Hi this is something that's really bothering me and I'm hoping someone has an
I have this really simple trouble I can't seem to overcome. I'm trying to
This really seems like a bug to me, but perhaps some databinding gurus can
I've got this really simple piece of code that I thought was the correct
This has been bothering me for a while, and I'm wondering if there's any
This is a question that has been bothering me for sometime. My application uses
This has been greatly bothering me in the past few weeks. In this time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.