Complicated MySQL Query

Why not just use WP_Query for this instead of inventing the wheel all over again? I’m pretty sure you can solve this with a meta query within your WP_Query. See the codex.

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