Only show first image in foreach loop

Depending of what you are exactly trying to achieve accessing the first element of the $posts array may work for you. No need for the foreach loop.

echo '<img src="'.$posts[0]['img']['url'].'">';

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