Jump to content
xisto Community
Sign in to follow this  
demolaynyc

Having Problems With Saving Xml File

Recommended Posts

Hi, I'm trying to make a guestbook using PHP and XML but I can't seem to save my XML when i try to save it. I use the XML.send() function to send the raw_post_data to be saved onto my guestbook.xml file. Somehow, it doesn't seem to save it. Can anyone help me?

Here's the php code

<?php  $filename = "guestbook.xml";$raw_xml = file_get_contents("php://input");print $raw_xml;$fp = fopen($filename, "w");fwrite($fp, $raw_xml);fclose($fp);?>

Is there anything wrong with this file that I don't see?
Can anyone give me an alternative php script?

Share this post


Link to post
Share on other sites

The only thing I can imagine that might be wrong is you file or directory permissions.If you don't set the directory and the file you want to save to write ALL, the file won't save and I don't think PHP will return an error. chmod to 666 for the file and 777 for the directory. That should solve the issue. If you already have your permissions set correctly, then I'll have to further evaluate the problem.vujsa

Share this post


Link to post
Share on other sites

Well, in your cPanel, do as follows:Goto: cPanel > File Manager > Click on Filename > Change Permissions > Read All, Write All.Do the same for your directory except click on the directory name instead of filename and it should be execute all as well.Be sure to click the name and not the icon. The icon takes you to that directory while the name gives you the options for that item in the upper right side of the window.For files, 666 is read all and write all.For directories, 777 read all, write all, and execute all. [/hr]With your FTP manager, the process is probably much different.Ususally, your local files are on the left side and the remote files on the right side. RIGHT Click on the remote file or directory name to display your options. Select change permissions or CHMOD! Use the same setting as above.Hope this helps.vujsa

Share this post


Link to post
Share on other sites

So I just tried you script on my home system and my hosting account and everything worked fine with the sample data I used which was just a username.

Are you looking in the right place for the saved file? It will be in the exact same directory as the script that saves it. It will not be in the root directory or any other place. So if your script is /scripts/save_guestbook.php then your XML file will be /scripts/guestbook.xml also!

Other than this, I have no idea what might be wrong! The script works unless there is somethin in your XML file causing problems.

Try changing $raw_xml = file_get_contents("php/input/;); to $raw_xml = "Test Data";

Hope this helps.

vujsa



Share this post


Link to post
Share on other sites

Yep, they're both in the same place. Hold on, I'll give you the url and you test it for yourself. I post a comment and it loads into the output TXT however when I go to a different page, it disappears.

Here's the AS code, please take a look at it and look for any errors.

var inputXML = new XML();inputXML.ignoreWhite = true;inputXML.contentType = "text/xml";inputXML.load("guestbook.xml");var outputXML = new XML();outputXML.ignoreWhite = true;outputXML.onLoad = function () {	gb_output ="";	var postElement = inputXML.firstChild.childNodes;	for (var i=0; i<postElement.length; i++) {		gb_output += "<b>Name: </b>"+postElement[i].attributes.name+"<br>";		gb_output += "<b>Date: </b>"+postElement[i].attributes.date+"<br>";		gb_output += "<b>Message: </b><br>"+postElement[i].attributes.message+"<br><br>";		gb_output += "__________________<br>";	}}outputXML.load("guestbook.xml");btn_submit.onRelease = function () {	var date = new Date();	var cDate = (date.getMonth()+1)+"-"+(date.getDate())+"-"+(date.getFullYear());		var node = inputXML.createElement("post");	node.attributes.message = form.gb_message.text;	node.attributes.date = cDate;	node.attributes.email = form.gb_email.text;	node.attributes.name = form.gb_name.text;		inputXML.firstChild.insertBefore(node, inputXML.firstChild.firstChild);	inputXML.sendAndLoad("GBaddPost.php", outputXML);	popup.gotoAndPlay(2);}	

http://forums.xisto.com/no_longer_exists/[8].swf --go to Fan ZOne page

<?xml version="1.0"?><guestbook><post name="Albert Villaroman" email="masugidsk8r@yahoo.com" date="10-14-2006" message="Yo man this is just a text but I think this test will work. I sure hope so man, I really do so please load and send it back to this movie please? THank you." /><post name="unnamed 1" email="nomail@domain.com" date="10-11-06" message="hello" /></guestbook>

Edited by demolaynyc (see edit history)

Share this post


Link to post
Share on other sites

Oh man, I can help all day with the PHP but the AS is not my area of knowledge. Never used it before. If you problem is on the AS side of the system, I won't be able to help. I'm really sorry.vujsa

Share this post


Link to post
Share on other sites

Somehow, eventually the comment posted is saved to the guestbook.xml after like hours of the time of post. So, the codes do work, but it doesn't save right away, it takes the next day for the update to show up. So what may be the problem?

Share this post


Link to post
Share on other sites

I bet it is your browser cache. Try saving something then clear your cache to see if it is there afterwards. If that is the problem, I'm not sure how to fix that without setting no cache on the entire website.Since this isn't reallt my area, I can't help too much but I know that PHP isn't waiting to save your file. The process is real time. There isn't any file upload buffer on the server for PHP to use other than the "temp" folder but that clears out when the script moves on to the next task. vujsa

Share this post


Link to post
Share on other sites

Alright, now I have no problems in Xisto but when I upload it to Hostway.com The PHP script doesnt work in that host site. I used php/input/ and $HTTP_POST_DATA.The same flash works here in Xisto but the hostway.com uses only 4.0 version. Does that cause the problem. If so, what code could I use to be able to save the guestbook.xml file?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.