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
https://forums.phpfreaks.com/topic/60878-solved-if-statement-question/
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?

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 :-)

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.