troubleshooting Question

Write a PHP script that manipulates an XML file

Avatar of Dreammonkey
DreammonkeyFlag for Belgium asked on
PHPXMLAdobe Flash
9 Comments1 Solution1510 ViewsLast Modified:
Hi all,
I made a flash movie that reads in data from an XML file
There is a form in the movie that the user can fill out, when the user clicks the SAVE button the data gets sent out through variables to a php file. The php file receives the data and generates an XML file.

This is actually working, but,
I want the PHP file to read in the old XML file first and then adding the new Vars to it, and that 's where you guys could help me, I found some exampes on the net, but I can't figure out how they actually work.

My XML is strucured like this :

<?xml version="1.0" encoding="ISO-8859-1"?>
<gigs>
<gig       day="07" month="06" year="2008"
      venue="Kavka"
      time="20.00u"
      info="met La Femme Belge"
      address="Oudaan 14"
      location="Antwerpen"
      moreInfo="Dubbelconcert, met The Valerie Solanas & La Femme Belge."
      link1="www.myspace.com/lafemmebelge"
      link2="www.kavka.be"
/>
</gigs>

As you would have guessed I want to add a child like this <gig day="**" month="**" ... /> between the <gigs> .... </gigs> Parent Nodes .

My current PHP script in the Snippet below...

PS: If this works I want to add a featue that can update/remove data as well, but hey, first things first !
PPS: I know this is sort of thing is usually done using databases, but I prefer getting it done this way...
PPS: here is a link to the Flash Movie : http://www.thevaleriesolanas.be/editgigs/editgigs.html 
I surely hope you can help me out !

Regards,
Dreammonkey
<?php
 
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$venue = $_POST['venue'];
$time = $_POST['time'];
$info = $_POST['info'];
$address = $_POST['address'];
$location = $_POST['location'];
$moreInfo = $_POST['moreInfo'];
$link1 = $_POST['link1'];
$link2 = $_POST['link2'];
 
 
$myFile = "test.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
 
$stringData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><gigs><gig day=\"" . $day . "\" month=\"" . $month . "\" year=\"" . $year . "\" venue=\"" . $venue . "\" time=\"" . $time . "\" info=\"" . $info . "\" address=\"" . $address . "\" location=\"" . $location . "\" moreInfo=\"" . $moreInfo . "\" link1=\"" . $link1 . "\" link2=\"" . $link2 . "\"/></gigs>";
 
fwrite($fh, $stringData);
 
 
if($fh) {  
echo "&verify=success&"; 
} else {  
echo "&verify=fail&"; 
}
 
fclose($fh);
 
?>
ASKER CERTIFIED SOLUTION
Dreammonkey

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros