Jump to content

[SOLVED] if statement question


realjumper

Recommended Posts

I can't see the forest for the trees today! Can someone expain to me why the following code doesn't work when the the first condition is true and the second condition is false?

 

In this example, health_safety (in the db) is set to 'No'....but investigator is set to 'Yes'? To my way of thinking the statement is saying "if health_safety is not equal to 'Yes' OR investigator is not is not equal to 'Yes' echo "Go Away".

 

So the example should read (according to the db) "health_safety = 'No' but investigator = 'Yes'" (therefore) 'Hello'

 

 

 

 


if ($row[health_safety] != 'Yes' || $row[investigator] != 'Yes')
  {
  echo "Go Away";
  exit()'
  }

else{
     echo "Hello";
     }

Link to comment
Share on other sites

Does this yield different results.....

 

<?php


  if ($row[health_safety] == 'Yes' || $row[investigator] == 'Yes')
  {
  echo "hello";
  }

    else
    {
     echo "I hate your face. Die.";
     exit;
     }

?>

 

Also...you did print out the values to see if they were outputting 'Yes' or 'No', right?

Link to comment
Share on other sites

Thanks Caesar....the 'if' statement works as you have it....but if neither condition is true ie I set both 'health_safety' and 'investigator' to "No" in the db, then the else staement doesn't work....in fact I just get a white page. Yes I did print out the values and they are fine :-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.