Limit to add one post per category only

I think the best is category-wise; I usually use this

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $posts = get_posts('category_name=['the category name(slug)']&orderby=rand&numberposts=1'); foreach($posts as $post)  ?>

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