Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a PHP script from within Flash. 1

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
Hi

With the help of people on the PHP board, I have managed to write a little piece of PHP that meets my (very simple) needs.

How do I run this (called PHPStoreVisitorInfo.php) script from within Flash, so that it runs behind the scenes of my main flash website.

It is just a stand alone script that requires no user intervention, all it does is write to a text file on the server with a date/time stamp and the visitors remote host address.

I do not need to pull in any variables at all back into my flash website, all I want it to do is execute the SWF file when someone visits my (flash) website.

What code in Flash do I need to use to run a PHP script behind the scenes? I though LoadVariables, but I guess this is not what I need since I dont actually want to pull any variables back into my flash site.

Any help much appreciated as always.
RM




 
You want the php to execute the swf file when someone access to your flash website....humm can't see the logic.
coz if someone access to your flash website, automatically the swf is excecuted ay?
oh well.
if you want to execute the php file when someone access to your Flash website use:

on (release) {
loadVariablesNum(" 0);
}
i think it will execute your php. i m not sure.but it s how i do. and how it works fine with me.
 
Infuriatingly, that doesnt work for me 123456programmer

(btw yes, I am trying to exectute a PHP from my Flash site, not the other way around (my mistake in orig question.

So I put this code in that you suggested (you missed a close double quotes I think (?), so in the first frame of the Flash it runs following code:

loadVariablesNum(" 0);

But it still doesnt work. Annonyingly when I just put into my web brower as the address and hit enter it does work, so it cannot be a text problem, it just doesnt seem to run it using that loadVariablesNum command.

I presume that your on release code was just because you run your own PHP script when you hit a button, I just want it to run in the first frame, (alongside another loadvariablenum command that I run). The first one runs, but the second one, the one that you advised me to use does not.

I am stuck! (very new to Flash, so any help much appreciated)

Anyway, here is the action script I have in the first frame of my flash (I have replaced by own domain name with webserver.com - but just to stress, if I put the correct full url (inclusive of the PHP script, it does work properly. It just isnt working when I try to run it via action script in Flash.

Any ideas?

loadVariablesNum ("PHPCounter.php?ran="+random(999), 0);
loadVariablesNum (" 0);", 0);



Many thanks
RM
 
what about you simply implent the flash <object> </object> part into your PHPStoreVisitorInfo.php... or better would be to use <? include... in the html... i ll explain

i went on the PHP forum and found the script you are using ( i presume that was the one) and i tried using &quot;loadVariablesNum&quot; and it worked fine...

<?php
$date = date(&quot;ymd-Hi&quot;);
$LogFile = &quot;log.csv&quot;;
$FilePointer = fopen ($LogFile, &quot;a&quot;);
fwrite ($FilePointer, &quot;\&quot;$date\&quot;,\&quot;$REMOTE_ADDR\&quot;,\&quot;$http_REFERER\&quot;\n&quot;);
fclose ($FilePointer);
?>

What you can do is this:
Publish your FLASH in html.
change the extension to .php
open the source.
add:
<?php include &quot;PHPStoreVisitorInfo.php&quot; ?>

hope it helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top