Passing a variable from Macromedia Director

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
myt
Forum Newbie
Posts: 3
Joined: Thu May 23, 2002 12:45 pm
Location: West Yorkshire, England

Passing a variable from Macromedia Director

Post by myt »

Hi People,

I am a total newbie to php, so this is probably going to sound like a pretty stupid question!

I work predominently with Macromedia Director and Flash, I need to pass a variable from Director to a text file on my server.

Currently I have, and try not to laugh,

<?php
$basic = fopen("text.txt", "a+");
fputs($basic, $testVariable);
fclose($basic);
?>

testVariable is the name of my variable in Director.

Any help would be so greatfully appreciated!!

Thanks in advance.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Okay, I don't know the command in ActionScript (or whatever it uses) but you would actually call the page:

page.php?variable_name=value

And of course, in your PHP script, $variable_name is now set (or $_GET['variable_name'] if you have register_globals off).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

...(or $_GET['variable_name'] if you have register_globals off).
in time this will be as famous as 'Censeo Carthaginem esse delendam' ;)
myt
Forum Newbie
Posts: 3
Joined: Thu May 23, 2002 12:45 pm
Location: West Yorkshire, England

Post by myt »

Watcha, thanks for the replies but I'm still having no joy!

I'm not even sure that I'm calling the variable properly in php.
Right, I need to write the contents of a variable to an external text file using php. So far I've got:

<?php
$basic = fopen("text.txt", "a+");
fputs($basic, $testVariable);
fclose($basic);
?>

With testVariable being the name of the variable in Director.

I'm calling the PHP:

global testVariable
on mouseUp me
getnettext("http://www.volume54.com/dcy4/app/add.php?", testVariable)
end

Is this right?

I really have no idea about PHP code so answers as 'newbiesafe' as poss please!

Thanks again.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you have two choices:
- keep
getnettext("http://www.volume54.com/dcy4/app/add.php?", testVariable)
and use
fputs($basic, $_SERVER['QUERY_STRING']);

- or keep
fputs($basic, $testVariable); // which may be $_GET['testVariable']
and name it in the querystring
getnettext("http://www.volume54.com/dcy4/app/add.php?testVariable=", testVariable)

in both cases make sure that <testVariable>
- does not contain any special characters
- or is escaped properly
myt
Forum Newbie
Posts: 3
Joined: Thu May 23, 2002 12:45 pm
Location: West Yorkshire, England

Many Thanks

Post by myt »

Hi again,

Thanks for all your help - got it working!

Really appreciated :lol:
Post Reply