If else.....the basic logic don´t work

Guys, today 8-10, I’m stuck with an IF with a condition that it pretends to say it’s true.If else then, they are conditional branch commands / statements since BASIC, 1989 … It’s 20:30 p.m and I’ve been at this since 15:00 p.m. I make a query via PHP, and return a string in the form of JSON. A string of any type [“error”] or [ ], or [""] or [1] … sometimes even an F! # $ @% @%. I print this response (response content) inside a text box for me to check. I put in IF: IF return is different from [“error”] I go in and give the message OK, RECORDED WITH SUCCESS. But the return is exactly the same as [“error”]. But I know from the logic of the PHP script, it didn’t go into the loop and didn’t insert it into. I go to the database and check that nothing was entered.

TELA3
Notice that I used comparatives of TEXT and Mathematical ( Green and Blue )
tela2
This image I divided the if into 2. In the first one was an IF with AND.

Yes, I used IF with AND comparing 2 alternatives
CONTENT
Yes I put quotes inside [“1”]
CONTENTSCREEN
This is the app screen
content3
It didn’t work either …
CONTENTSCREEN2
I used length - trim = 4 …don´t work…
compara
the response content and the comparison string … identical …
it did not work

AND FINALLY …
meleca

And finally after 6 hours …
it worked … but this solution already gave me problems in another app. The use of compare text, did not work in another situation and today (I did not expect it) she who solved.
Sorry, I do not know if it was to post because it was resolved. But I don’t understand why 2 identical strings are being compared and return FALSE.
I NEED A BEER !!! :joy:

1 Like

" and ” aren’t the same character.
Make sure you are using the correct one.

1 Like

What do you mean, “It’s not the same character?” It didn’t just happen with AND. Note that I divided it into 2 IF’s (wrongly). I first tested one condition and then the other.

Did you print your response content that is it in json format please mention that response to see what happen

Yes. The content “RESPONSE CONTENT” is of type JSON because in the PHP script it has
----> echo json_encode ($data);
And in the KODULAR block itself I print “RESPONSE TYPE” and show JSON / TYPE

I was referring to the quote characters not the and.
There are multiple characters that look like a quote but they are different when comparing.

Example of 3 different quote characters (“ " ”)

I was just trying to mention 1 possibility as to why your Strings didn’t match even though they appeared to be the same.

OK…:smile:
But, did you see that I could solve it? But the point of this topic is that I solved, but I don’t know why IF doesn’t work. And I didn’t see the logic for the other attempts not to work. Now does it work? Yes it works, but the next time I need a SIMPLE “If” I will not know if it will work and how it will work … understand my concern?

1 Like

Did you try json utilities extension to get array from json.

  1. For testing that if condition works or not you should print any text in label after if and before coding.
  2. Try removing square brackets in logic equal

“Try removing square brackets in logic equal”
This I know I can not do because I know that the return of the php script in Json format, brings 2 square brackets. I already posted this solution in another post here in the forum.