Uploading and attaching images through php

Hi all,

This isn't WPMU specific but I am tearing my hair out with this.

Basically, for each post that is published I check to see if there is an image in it, retrieve the image and then attach it to the post properly. The posts are coming from RSS feeds and so do not have images attached as they would usually.

So here is the code:

$attachment = array(
'post_mime_type' => $mime,
'guid' => $url,
'post_parent' => $post_id,
'post_title' => $title,
'post_content' => "",
'post_exceprt' => ""

$id = wp_insert_attachment($attachment, $file, $post_id);
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));

// We need to do this to get rid of the frickin long description in the attachment and set the caption
$my_post = array();
$my_post['ID'] = $id;
$my_post['post_content'] = "nothing!!!! aaaaarghghghghgh!";
$my_post['post_excerpt'] = $post->post_title;

// Update the post into the database
wp_update_post( $my_post );

No matter what I do the whole content of the parent post is saved as the "post_content" (which is the description of an attachment). Even running the wp_update_post after it explicitly stating to change the content doesn't work - although it does update the exceprt correctly so it is changing something. The post_excerpt is the caption field on an attachment.

Any ideas????