PDA

View Full Version : Loading and writing from the same file


Siempy
12-18-2005, 08:40 PM
Hi,

I recently managed to write and load from an xml encoded file via Flash. I used the LoadVars object to send the string of the Xml object to php, and then writing that to a file. To load the xml data again, I just used the xml.load function.
I have now encountered an annoying problem, because after loading from a file, I cannot seem to write to the same file a short while after. I can however write to that file when I have not loaded from it and I can write to a file after loading from another. Could this have something to do with writing access after loading the file directly via flash?
Any help is much appreciated :)

Ignifex
(don't mind the username, it's old. can't I delete my older account?)

Flash Gordon
12-18-2005, 08:49 PM
the are independant of each other: loading and writing, (almost) completely unrelated.

Post some code and I'll look at it.

Siempy
12-18-2005, 08:58 PM
this is the flash code:
stop();
XmlData = new XML();
XmlData.ignoreWhite = true;
XmlData.load("gencontents.xml");

XmlData.onLoad = function() {
_root.theoldtext.text = XmlData.firstChild.firstChild.firstChild.nodeValue ;
}

_root.sendbutton.onPress = function() {
sendData = new LoadVars();
returnData = new LoadVars();
XmlData.firstChild.firstChild.firstChild.nodeValue = _root.storylinebox.text;
sendData.xmlData = XmlData.toString();
sendData.sendAndLoad("gen_xmlwriter.php",returnData,"POST");
}
And the gen_xmlwriter.php:
<?php

$FileName = "gencontents.xml";
$fp = fopen($FileName, "w");

$output = $_POST['xmlData'];

fwrite ($fp, $output);

print $output;

fclose ($FilePointer);

?>
And, if is of any interest, the gencontents.xml file:
<?xml version="1.0"?>
<contents>
<storyline>The storyline pwnage!</storyline>
</contents>

CyanBlue
12-18-2005, 09:01 PM
Ignifex
(don't mind the username, it's old. can't I delete my older account?)
What is the other user name that you want to delete???

Siempy
12-18-2005, 09:04 PM
I simply don't use the name "Siempy" anymore. That was when I was about 12 or so. I changed my nickname to Ignifex. So I would like to delete my older account of Siempy and start a new one as Ignifex. I only have one email adres, that's mainly the problem.

CyanBlue
12-18-2005, 09:10 PM
I cannot do that for you but if you PM Jesse or Strok, they should be able to handle that for you... Just ask them to rename your user name... No need to delete/create another one...

Flash Gordon
12-18-2005, 09:14 PM
I'm not sure what your problem is. However, with the scripts attached I have no problem loading and then writing to the same file. Upload them and test if you like. Let me know if that helps any :)

Siempy
12-18-2005, 09:50 PM
I had a look at your code and uploaded it. It showed the "Hello world" message as one would expect, but it did not give me any change to the text file. After changing the php file to write to a text file called file2.txt, it created a new file, with the changes that should have been made (it indeed gave my ip).
If the script did work for you and changed the file, then it is apparently not a scripting question, right?

Flash Gordon
12-18-2005, 09:56 PM
It showed the "Hello world" message as one would expect, but it did not give me any change to the text file.Weird, i got a change on my server! Perhaps it is a cache issue. I bet you are using IE, right? Yeah, like you said, not scripting. I betting cache. You could always try to add a cache killer, but I'm not sure how if you can append that to an xml file of not
var num:Number = Math.round((Math.random()*1000));
LV.load("file.xml?cacheKiller="+num);

Siempy
12-19-2005, 08:18 AM
Nope, still nothing :/
Could it have something to do with permission settings? Maybe execute should be allowed?
Some programs open files and keep them opened, so the file can't be written to while it is used by the program. But that wouldn't explain why it does work on your server.
Hmm... I really have no idea why this is happening :/