|
-
[AS2] Saving: code doesn't work.
Hey everyone,
Okay, I know this is an old topic by now. I've searched numerous places how to save to a simple text file, and at one point in my life I was able to do it. However, the code doesn't seem to work anymore ...
Flash Code:
Code:
myData = new LoadVars();
submit.onRelease = function() {
myData.Name = textbox.text;
myData.sendAndLoad("save.php",myData,"POST");
}
PHP Code:
PHP Code:
<?php
$name = $_POST['Name'];
$toSave ="Name=$name;"
$fp = fopen("saveLocal.txt", "w");
fclose($fp);
?>
Very simple it would seem, but it doesn't work. Thoughts?
-
FK'n_dog
try -
PHP Code:
$myfile = fopen("saveLocal.txt","w");
$fp = fwrite($myfile,$toSave);
fclose($myfile);
-
I've tried it and it doesn't work either. The thing is, it all makes perfect sense ... yet it just doesn't want to work!
-
FK'n_dog
try -
PHP Code:
$toSave ="Name=".$name;
-
i use get and post function in flash then use arrays in php like [_$post] kinda like that but just mess around with what you have got nd it will eventualy work
-
ohh i see its the php that aint working, you should use mysql and it might be your chmmod or whatever it is called on the saveLocal.txt file
-
Still nothing, although what you wrote would make sense. Also, Milna, what do you mean by my 'chmmod' (or whatever it is, haha :P)
I don't remember ever having to alter a text file. But then again, I did it two years ago so I don't remember anything.
-
Here , this was on a tutorial somewhere, it sends the player a cookie, I dont know, maybe you dont want to do it that way?
But here is the code, I dont remember where i got this tutorial.
You do this part once, let it fire at the beginning of game loadup
var thevar = 0;
Code:
function dothing (){
Object.prototype.setCookie = function(c, n, v) {
var so = SharedObject.getLocal(c);
so.data[n] = v;
so.flush();
};
Object.prototype.getCookie = function(c, n) {
var so = SharedObject.getLocal(c);
return so.data[n];
};
}
You put this on your save button
Code:
this.setCookie("mv","myvar", thevar)
and this on your load button
Code:
thevar = this.getCookie("mv","myvar")
thevar obviously being the variable you want to save, but you can use arrays too of course.
I hope that helped, but im guessing not because you were using a different method
-
Yeah a cookie would work, but not for what I had in mind. I just wanted to simply save some information so that if anyone goes to a given link, the information can be retrieved.
-
chmmod is the 3digits that give the permissions to a file for example "755" etc. on some servers it can also be called set permissions or just permissions on a file,for php file to access and edit another file onthe server it needs the file its editings permissions changing, heres 2 links to explain it in more detail if you dont understand
http://codex.wordpress.org/Changing_File_Permissions
http://www.stadtaus.com/en/tutorials...ermissions.php
-
That's interesting. I checked the PHP file and it was set to 'write' under all three types of users. It's just ... I found it really simple back in the day when I was doing this. I wonder if things had changed?
But I was using CS3, so I'm not sure why it's not working anymore. :'(
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|