WordPress WP_Query() Not working properly

I was having a similar error when using a WP_Query as given at
https://wordpress.stackexchange.com/a/42334/16898.

I replaced the variable name $posts with an arbitrary name $mposts and the error was gone.

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