Hi all

I hope you can help. I'ma first-time poster, newish lurker(this place is a godsend!), learning PHP at the moment. I would love to build functionality to a site I'm playing around with that will enable me to fill out a form to send news content to a PHP file where it will append an XML document. From that I can pull the XML feed on to an area on the site for news.

I have the form writing to the PHP file and the PHP file *should* be appending the XML file. However, what I find is that it appends once, and then keeps overwriting that one position. My If statement to see if I should append to the XML is like this:


//if statement to see if stuff is on the array or not
if ($thisPos==-1)
{
echo " its NOT on the ARRAY thisPos value is $thisPos so we need to append";
$elementPos = $lengthOfArray;
}
else
{
echo " ITS on the ARRAY cos it's at position $thisPos so we need to over write";
$elementPos = $thisPos;
}


Then I update the array using this:


$person_data[$elementPos]['storytype'] = $storytypeContent;
$person_data[$elementPos]['headline'] = $headlineTagContent;
$person_data[$elementPos]['bodytext'] = $bodyTextInput;
$person_data[$elementPos]['abstract'] = $abstractConent;


What's happening is that the XML file starts out with an array of 6 items numbered 0-5. If I write to the XML file, I will get an item 6 displayed because I'm using the

print_r ($person_data);

line to see what has been written. However, no matter how many times I write to the array, it only writes over item no. 6, whereas I was expecting it to keep appending. Also, when I take the XML file down from the server, it doesn't seem to have been written to at all!

I'd really appreciate some input on this cos I'm sure I've done something stupid but really need a fresh pair of eyes to check out the code!

Any ideas?

Thanks in advance, diddle