Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Having Problems With Saving Xml File
demolaynyc
post Oct 14 2006, 03:13 PM
Post #1


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



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?
Go to the top of the page
 
+Quote Post
vujsa
post Oct 14 2006, 07:24 PM
Post #2


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post
demolaynyc
post Oct 14 2006, 11:16 PM
Post #3


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



how would i fix that chmod in astahost? Sorry but I don't know how to configure these settings.
Go to the top of the page
 
+Quote Post
vujsa
post Oct 14 2006, 11:28 PM
Post #4


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post
demolaynyc
post Oct 14 2006, 11:31 PM
Post #5


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



Ok, I changed the permissions, but they're still the same
Go to the top of the page
 
+Quote Post
vujsa
post Oct 15 2006, 12:22 AM
Post #6


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post
demolaynyc
post Oct 15 2006, 12:33 AM
Post #7


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



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>


This post has been edited by demolaynyc: Oct 15 2006, 12:46 AM
Go to the top of the page
 
+Quote Post
vujsa
post Oct 15 2006, 02:36 AM
Post #8


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post
demolaynyc
post Oct 16 2006, 05:29 PM
Post #9


Premium Member
Group Icon

Group: Members
Posts: 330
Joined: 2-February 06
Member No.: 11,040



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?
Go to the top of the page
 
+Quote Post
vujsa
post Oct 16 2006, 08:31 PM
Post #10


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Shut Down, Restart, Log Off XP Using A Batch File(23)
  2. How To Save A Image In Pdf File And Download It?(10)
  3. Nero Problems(28)
  4. Recover Tables From A MySQL .frm File(8)
  5. Freebsd Burning & Installation Problems(4)
  6. What Is Mkv? Need Help With This File Format?(6)
  7. Uploading Image File Through JSP Code To Server(9)
  8. How To Use Psd File(14)
  9. Problems Installing Vista(13)
  10. How Do You Use The cPanel File Manager?(13)
  11. Deleting A Corrupt File(25)
  12. Need Help Urgently (missing Or Corrupt Hal.dll File).(6)
  13. Office 2007 Document Problems(12)
  14. Internet Connection Sharing Problems(2)
  15. Is A Php File Searchable?(8)
  1. Problem With Move_uploaded_file()(5)
  2. Safari And Hosts File(8)
  3. Two Problems.(5)
  4. How To Copy File & Folders From Linux To Windows?.(12)
  5. Existing Problems(4)
  6. Need To Edit A Wav File [solved](1)
  7. Re-ordering Welcome Screen & Moving Heavily Fragmented File(1)
  8. Updating Graphics Card Problems(11)
  9. Skydrive(5)
  10. Mysql And User File_priv(0)
  11. Gimp: Saving As... Issues(3)
  12. Image Problems With Windows 2000(8)
  13. Wamp Server Problems(4)


 



- Lo-Fi Version Time is now: 5th September 2008 - 12:37 PM