Thanks for your answer.
I upload the script here. Maybe you can tell me what i did wrong.
It's maybe just a simple something but i'm not so good in scripting at all. Thanks again for helping.
Sorry post it wrong. It had to be a reply on the last post.
When i do that, changes in the text are not writen to the txt file on the server. My PhP script looks like this. I changed the $_post it was $_get before. Was that what you ment. Also the movie file wich i edit. I think the way you say it must be.
<?php
$file_name="./test.txt";//Be sure to set this to your file
if ($_POST['cmd']='w'){
//to write a file
$fp=fopen ($file_name,'w');//open file for writing
fwrite($fp,"&var1=".$var1);//save what ever is in the string contents
fclose ($myfile);//close it
}else{
//open a file and assign it a 'handle' of fp
$fp=fopen($file_name,'r') ;
//Then read the file
$contents = fread ($fp, filesize ($file_name));
fclose ($fp);//done close the file
}
//either way I think it's ok to send the contents back to 3dfa
//so send it
echo "&var1=".$var1;//change this to the variable you use in 3dfa
?>
where do i have to define this variable.
When i push the button or at the start of the movie.
How do i make that variable. : like cmd="W" (capital or not)
I tried it at the start of the movie but that didn't do the trick
So this is my php file. As you can see the post['cmd']='w'
I defined a variable cmd='w' in the script section.
When i change the tekst and push the tekst opslaan button (save text button) then there is nothing saved. I really don't know what i'am doing wrong. Can you help me again.
<?php
$file_name="./test.txt";//Be sure to set this to your file
if ($_POST['cmd']='w'){
//to write a file
$fp=fopen ($file_name,'w');//open file for writing
fwrite($fp,"&var1=".$var1);//save what ever is in the string contents
fclose ($myfile);//close it
}else{
//open a file and assign it a 'handle' of fp
$fp=fopen($file_name,'r') ;
//Then read the file
$contents = fread ($fp, filesize ($file_name));
fclose ($fp);//done close the file
}
//either way I think it's ok to send the contents back to 3dfa
//so send it
echo "&var1=".$var1;//change this to the variable you use in 3dfa
?>
I changed the POST to GET and called it in the browser.
Underneath is what i get
Warning: fclose(): supplied argument is not a valid stream resource in /usr/local/plesk/apache/home/vhost/rmvos.nl/httpdocs/ruiter/test.php on line 8
&var1=test text
The txt file was filled with &var1=test text
When i change the POST to GET again then it writes in the txt file.
Does this make sense ?
Here's What I suggets make a form in HTML that sends a textfield to your PHP so you can test it.
You can use print_r to see the array either print_r($_POST) or print_r($_GET) so you can see that your variables are as expected in the PHP code then debug your PHP till it's working then its a simple thing to have the 3dfa send the vars instead of the HTML form.
thanks again for the answer Blanius.
But i'am not clever enough to get it to work.
Can you have a look at it again please ?
the php file on the server is like this now:
<?php
$file_name="./test.txt";//Be sure to set this to your file
if ($_POST['cmd']='w'){
//to write a file
$fp=fopen ($file_name,'w');//open file for writing
fwrite($fp,"&var1=".$var1);//save what ever is in the string contents
fclose ($fp);//close it
}else{
//open a file and assign it a 'handle' of fp
$fp=fopen($file_name,'r') ;
//Then read the file
$contents = fread ($fp, filesize ($file_name));
fclose ($fp);//done close the file
}
//either way I think it's ok to send the contents back to 3dfa
//so send it
echo "&var1=".$var1;//change this to the variable you use in 3dfa
?>
I include the movie as a zip file. Is the movie oke ?
I hope you can help me it is driving me INSANE ;-)
Rob it's hard to diganose without actually testing myself on server.
That being said I've found another problem with the php file.
the line
PHP Code:
if ($_POST['cmd']='w'){
should be
PHP Code:
if ($_POST['cmd']=='w'){
Also move the cmd="w" into the button script, and it's better to put it into the Button up instead of down, this is the way standard buttons work that way you can drag the mouse off a button after pressing and not activate the button actions.
i cant get it to work. I made a change tot the script it looks like :
<?php
$file_name="./test.txt";//Be sure to set this to your file
{ //to write a file
$fp=fopen (test.txt,'w');//open file for writing
fwrite($fp,"&var1=".$var1);//save what ever is in the string contents
fclose (test.txt);//close it
}
?>
This shoud always write to the text file i suppose.
See the movie. I changed the button etc. Does it have to be on a server? I mean i have the txt file and the php file on the server and the movie on my c drive. I thought that had to be possible.
I'am going away for a few days (till thursday next week) so i wish you a happy ending and a jolly good newyear. Thanks for all the help and i hope i can get it to work next year ;-)
Get the PHP working with GET so you can test by typing in the url. then just switch to POST and then use 3dfa to send data. And yes you can test local.
when i push the button i see the text from var1 become your line "this is data send from 3dfa". But it is not saved inside the text file.
I have webspace by protagonist. You don't know them probably.
I don't know what to do next. Is there another way to send variables to a text file ? Maybe another script ?
Rob, I don't know what else to tell you Flash cannot save information to the server itself and the PHP code I know works if your permissions are set right.
It works. I made it just like you said and was testing it from a movie on my computer. I compiled it and upload it to my server. Now it is working. So i think i have to do it real 'live' on the server and not the movie local and the rest on the server.
as you can see i have to define the test.txt file in the php file.
Is there a possibility to define the $file_name like a variable.
That way i can set up the movie to connect to the right txt file.
Like in the button something like $file_name="test.txt" The problem is that 3df don't allow me to use $file_name as variable. This way i can use one php file to write to many txt files.
<?php
$file_name="./test.txt";//Be sure to set this to your file
if ($_POST['cmd']=='w'){
//to write a file
$fp=fopen ($file_name,'w');//open file for writing
fwrite($fp,"&var1=".$var1);//save what ever is in the string contents etc etc.