Go to full version

Projects On Hex.ro - Questions and Answers > Macromedia Flash XML Tutorial

save.php source code not available for download.

<< < (2/3) > >>

viulian:
Thanks :)

About appending nodes to an XML file instead of writing it down from zero... there are a couple of solutions.
If you run PHP 5, you can use http://php.net/simplexml to read the XML sent from flash [pick up the nodes that is] and then read update the XML on disk with the new nodes.

For older PHPs, you can search the web for something like PHP XML class, or PHP xml simple.. and pick up the one best suited for your goal.

But there is a problem: what would happen if two users would click 'Save' and then the web server will try to update the XML on disk with two changes simultaneously ? One of the changes will be lost when the script that runs last will update the file on disk.
If you want to save data on disk and plan on offering the flash to >10 users which might click Save at the same time, I guess it's better if you save each request separately. Then, when you want to access the data saved as XML, you will just read all the files and create a big XML and then use that..

---

About the redirect ...
I think it will try to do the redirect anyway (if you press on Save because it does a POST) so the choice would be to redirect to the same page containing the flash which lets the user enter the data (basically a reload).
Or maybe you can change the 'Save' button properties and make it not to be a submit button, but a simple button (which won't trigger a redirect but just make a background call to the save.php script - AJAX like behaviour, for example).

I don't have Macromedia anymore - did this tutorial a year ago or so, so that as far as I can help..

Infiniti Productions LLC:
Again thank you.  I think by the end of this I might know PHP.  Thank you for the tip about >10 users although it is for a website customer's testimonials - i doubt it will become very popular.  You have been great.

viulian:
Thank you too :) and good luck!

Infiniti Productions LLC:
its working very well... i figured something out.
if you just replace your "w" with "a" in fopen, it will append onto the xml file instead of overwriting.

Peace.

viulian:
Well :) "a" means append..
I don't think it will be a well formed XML what you get, because you will have something like:


--- Code: ---<root>
  <value>
    10
  </value>
</root>
<root>
  <value>
    10
  </value>
</root>
--- End code ---

Which is not a good XML as it doesn't have a root node - a single node that embeds everything else..

But if you can parse this structure which is not a well formed XML, then it's ok I guess.

For more reading: http://en.wikipedia.org/wiki/XML where it says:

Every XML document must have exactly one top-level root element (alternatively called the document element), so the following would also be a malformed XML document: it has two top-level thing elements, with no overall parent element encasing them both.

<?xml version="1.0" encoding="UTF-8"?>
<!-- WRONG! NOT WELL-FORMED XML! -->
<thing>Thing one</thing>
<thing>Thing two</thing>

Navigation

[0] Message Index

[#] Next page

[*] Previous page