$wpdb->flush(); breaks the loop

In the code you posted in your other question, your call to flush() is using the wrong variable: $wpdp->flush();.

Since this is an undefined variable, it’s likely that you’re simply getting a PHP runtime error at this point, stopping page execution.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)