Page 1 of 1

Passing a variable from Macromedia Director

Posted: Thu May 23, 2002 12:45 pm
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.

Posted: Thu May 23, 2002 1:22 pm
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).

Posted: Thu May 23, 2002 1:49 pm
by volka
...(or $_GET['variable_name'] if you have register_globals off).
in time this will be as famous as 'Censeo Carthaginem esse delendam' ;)

Posted: Thu May 23, 2002 2:06 pm
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.

Posted: Thu May 23, 2002 2:57 pm
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

Many Thanks

Posted: Thu May 23, 2002 3:00 pm
by myt
Hi again,

Thanks for all your help - got it working!

Really appreciated :lol: