if(!$sqlStr==$sqlStr1){
       echo $sqlStr;
    }else{
       echo $sqlStr;
       echo "<br>";
       echo $sqlStr1;
       echo "<br>";
       echo "No changes were made!<br>";
   }

This statement produces the same results whether or not the "!" statement is included.
e.g. if(!$sqlStr==$sqlStr1) produces the same results as if($sqlStr==$sqlStr1) Why?

Recommended Answers

All 7 Replies

Try replacing (!$sqlStr==... with ($sqlStr != ...

That worked.

Thank you.

That worked.

Thank you.

This kind of made me angry. Do you understand why xan's fix worked? Do you understand the operator precedence that is taking place between your statements? Are you aware of necessary disambiguation to avoid these issues? Or did you just accept it as "OK, now it works"?

if($sqlStr != $sqlStr1){ echo $sqlStr; }
else{  echo "$sqlStr <br> $sqlStr1 <br> No changes were made! <br>"; }

kis

I am very new to php but I am a very experienced programmer. I will do my research and seek to understand the "why." I am also very new to forums and will probably make more mistakes in etiquette as I gain experience in both.

Thank you both.

Your original version was evaluating

(not a) equal to (b)

when you wanted

(a) not equal to (b)

Again, thank you. That saves me some research as well as frustration in debugging. Also, I apologize for the mistake in sending a PM. The mistake resulted from inexperience in forum etiquette.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.