You both misunderstand the concept of "return". You cannot mix wait and return.

The first possibility is that sql_get_rows immediately returns a value. In this case iResults has a meaningful value and waiting may either happen forever (because sql_get_rows returned -1) or may not happen at all (because sql_get_rows returned something different).

The second possibility is that sql_get_rows does not return anything. In this case iResults is either random or remains at -1. I don't know. try it if you're interested.

Regardless of the possibilities described above iResults will never change afterwards so that the while loop is pointless.


Always learn from history, to be sure you make the same mistakes again...