Hello there,
I need help urgently on this one, so if anyone could assist i'd be so thankful,
The Problem;
i'm adding new entries from a form into a XML file, so i need to keep the structure of the XML intact, as you can see below, the new entries need to fit between the olddata ($olddata) and the </gallery> tag. I'm having differculties acheiving this;
<gallery>
<imageurl>image_006.jpg</imageurl>
<captiontext>this is a image</captiontext>
<imageurl>image_007.jpg</imageurl>
<captiontext>this is a image</captiontext>
New Entries need to enter here<<
</gallery>
this is my current PHP
[code=php]<?php
$Submit = $_POST['Submit'];
if(isset( $Submit )) {
$Submit = $_POST["Submit"];
$post = $_POST["edit_chi"];
$post = ereg_replace('[^A-Za-z0-9 \@\.\-\/\'_\~\:"<=>#|]', "", $post);
$post = stripslashes($post);
$filename = "gallery.xml";
$fp = fopen($filename,"r+");
$old_data = fread($fp, 80000);
fclose($fp);
$input = "$post";
$new = str_replace( $old_data$input ,' </gallery>');
$fp = fopen( $filename,"w");
if(!$fp) die("&error =Failed to write!");
fwrite($fp, $new, 800000);
fclose( $fp );
} [/code]
i know it has something to do with the way this is coded;
$input = "$post";
$new = str_replace( $old_data$input ,' </gallery>');
Thank You