Having Problems With Saving Xml File

Pages: 1, 2
free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > ActionScript

Having Problems With Saving Xml File

demolaynyc
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
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?

Reply

vujsa
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

Reply

demolaynyc
how would i fix that chmod in astahost? Sorry but I don't know how to configure these settings.

Reply

vujsa
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.


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

Reply

demolaynyc
Ok, I changed the permissions, but they're still the same

Reply

vujsa
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

 

 

 


Reply

demolaynyc
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.

CODE

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://demolaynyc.astahost.com/project1/index_v4[8].swf --go to Fan ZOne page

CODE

<?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>

Reply

vujsa
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

Reply

demolaynyc
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?

Reply

vujsa
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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Similar Topics

Keywords : problems saving xml file


    Looking for problems, saving, xml, file

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for problems, saving, xml, file
advertisement




Having Problems With Saving Xml File



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE