Jump to content

if statment with several conditions


yoda699

Recommended Posts

Hi,

I am trying to create an IF statement with several conditions.

What I am trying to achieve is actually three conditions:

 

1. $num_errors > 0

2.  And $field != "curpass"

3.  Or $field != "newpass"

 

I wrote the statement using AND (&&) + OR (||) operators in the same statement, but it doesn't work.

Could please look at my code and tell me whats wrong. Is it even possible to do what I am trying to do?

 

Thanks ahead,

 

 

if ($this->num_errors > 0 && $field != "curpass" || $field != "newpass"){
         return "<img src=\"../images/check.jpg\" alt=\"\" width=\"34\" height=\"34\" />";  //Errors with form
      }
  else{
         return "";

 

 

Link to comment
https://forums.phpfreaks.com/topic/182747-if-statment-with-several-conditions/
Share on other sites

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.