Are you calling the get_posts function before running through the for loop? For example, I use this code in my website to get attachments:
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $page_id );
$attachments = get_posts($args);
What that is saying is that I want to get all of the attachments for the post/page with the id $page_id.
After you do that you should easily be able to get the attachment URL.
Ok, well I learned that the attachment functions are looking for the attachment ID and not the ID of the post they’re attached too. I’ve tried this code:
<?php query_posts('category_name="main page"&showposts=3');
while ( have_posts() ) : the_post(); ?>
<div class="panelContent">
<?php $images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',)); ?>
<img class="panelPhoto" src="<?php echo wp_get_attachment_url($images[0]->ID); ?> "/>
But I’m still having the same problem. The src attribute of the image tag still comes up blank. Any ideas?