Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-03-2001, 09:28 PM   #1
flashlite
Registered User
 
Join Date: Feb 2001
Location: Levittown, N.Y.
Posts: 25
Default

Does anyone know of a php file that can be used to pass variables from a flash swf to a txt file on the server?


Flashlite
flashlite is offline   Reply With Quote
Old 03-03-2001, 11:59 PM   #2
FlashGuru
Flash'a'holic
 
Join Date: Dec 2000
Location: London, UK
Posts: 82
Send a message via ICQ to FlashGuru
Default

Havent seen a php one, might be an idea for me to code one and distribute it but anyway, there is a perl version at:

http://www.kessels.com/flashdb

FlashGuru is offline   Reply With Quote
Old 03-04-2001, 04:01 AM   #3
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

It's almost exactly the same with PHP. I used PHP to store my variables for FlashCHess ( http://flashchess.cjb.net if it's even still up ) in temporary text files on the server.

My code was something like:

Code:
<?php $fd = fopen("tempFile.txt", "w");
fwrite($fd, "blah blah blah blah");
fclose($fd); ?>
it couldn't be much easier than that!
I trigerred this running using a LoadMovie command from Flash and GET as my variable post method (int he background so the user stays in the Flash file and doesn't see the PHP page ever).

For more info try http://www.php.net/manual/en/function.fwrite.php

Cheers

Jesse
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 03-04-2001, 04:16 PM   #4
FlashGuru
Flash'a'holic
 
Join Date: Dec 2000
Location: London, UK
Posts: 82
Send a message via ICQ to FlashGuru
Default

only one problem with that jesse, ampersands are taken as the start of new variables, hence sending the text so that it can be read back into flash is not possible with your script
FlashGuru is offline   Reply With Quote
Old 03-04-2001, 10:36 PM   #5
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

Nah nah it is. See I used that script orriginally for just that purpose. Here's the orriginal:

Code:
<?php $fd = fopen("$session.txt", "w");
fwrite($fd, "turn=$turn&captured=$captured&piece=$piece");
fclose($fd); ?>
(note this has been editted coz it passed like 30 variables )

it outputs plain text with ampersands which I read back into the other user's computer.. taht how I got interaction between 2 comps over the net

Cheers

Jesse
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 03-05-2001, 11:46 AM   #6
flashlite
Registered User
 
Join Date: Feb 2001
Location: Levittown, N.Y.
Posts: 25
Default

I really don't know much about php/cgi scripting. Basically I have a slight idea as to configuring if there is a readme file to show me but otherwise I'm a real beginner. Jesse, on this php script fo yours, what exactly needs to be configured, and how?

Flashlite
flashlite is offline   Reply With Quote
Old 03-05-2001, 05:09 PM   #7
FlashGuru
Flash'a'holic
 
Join Date: Dec 2000
Location: London, UK
Posts: 82
Send a message via ICQ to FlashGuru
Default

yes but jesse if you do this:

<?php $fd = fopen("$session.txt", "w");
fwrite($fd, $variables);
fclose($fd); ?>

then use:

loadVariablesNum("thephpscript.php?variables=hello &variable2=tester",0)

php recognizes the variable called "variable 2" as a new variable for the script, not a part of "variables"
FlashGuru is offline   Reply With Quote
Old 03-06-2001, 01:11 AM   #8
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

Ahh right Guru, I see your point. Oh well, the problem never arose for me

FlashLite, ok let's look at the script:
Code:
<?php $fd = fopen("tempFile.txt", "w");
fwrite($fd, "turn=$turn&captured=$captured&piece=$piece");
fclose($fd); ?>
Line 1:
Tells the server we're using PHP. opens a file 'tempFile.txt' for writing to. (ifthe file doesn't exist, create it).
Line 2:
writes to our open file whatever is within the quotes.
Line 3:
closes the file.

The main bit you need to change is the second line... OK so let's say you have a flash movie with a text field into which a user types their name. then you want to output their name to this PHP script (and thus into a text file on the server). We're goign to have to pass your variables from Flash into the PHP script which is done in this way:

loadVariablesNum ("thephpscript.php", 0, "GET");

This can be on a button or a keyframe or whatever. Doing it this way means it happens without the user being taken from flash using GetURL is also possible but it would mean the user is taken out of the flash file.

Now we've specified the GET method for passing our variables to the script. So all we need to do is tell the PHP file the name of the variable we want it to write out to the text document. Variables in PHP are preceeded by the dollar sign ($) so if we wanted to write out the value of variable 'name' into a text file, our PHP would be:

fwrite($fd, "$name");

It's that easy.

if you wanted to write it out so it could be read back into flash later in the form:
name=TheName
you would do this:

fwrite($fd, "name=$name");

Not hard huh?

For more info checkout http://www.php.net
The manually is really very easy.

Note this will only work on a webserver which supports PHP so it wont work on your local computer HDD

Cheers

Jesse
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 03-06-2001, 03:44 AM   #9
flashlite
Registered User
 
Join Date: Feb 2001
Location: Levittown, N.Y.
Posts: 25
Default

Thanks a lot. It is fairly simple. Now what is you want to be able to append the text file so u can add a series of users??

Flashlite
flashlite is offline   Reply With Quote
Old 03-06-2001, 05:06 AM   #10
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

Replace the w with an a for 'append'.

http://www.php.net/manual/en/function.fopen.php

It's all there in the manual.

Cheers

Jesse
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variables to flash - too long? babagadude Server-Side Scripting 2 06-03-2004 01:52 PM
passing Variables to a SWF file with GET Method Faycal ActionScript 1.0 (and below) 1 09-16-2003 09:29 AM
using variables in external text file while running *.exe dartagnan324 Projectors and CDs 1 08-07-2003 04:14 AM
Problems passing string variables? rsomers ActionScript 1.0 (and below) 0 03-17-2003 09:29 PM
Can we load variables from external file? tuyle ActionScript 1.0 (and below) 3 12-12-2002 07:02 AM


All times are GMT. The time now is 03:13 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.