ActionScript 2 to PHP variable passing, save to file

  • maradona2011
  • Born
  • Born
  • maradona2011
  • Posts: 1

Post 3+ Months Ago

Hi,

So ahead, I'm quite a newbie in PHP and ActionScript...;-)
In recent days I've worked through much trial and information from the Internet a bit in the two languages.
However, I've been trying unsuccessfully a few hours, the AS 2 - pass variable z to PHP and then store in a file, and so slowly you go from me ideas, what's wrong...

So this is the relevant part of ActionScript 2 code:

z = 39;
var erg: LoadVars = new LoadVars ();
erg.variable1 = z;
erg.sendandload ("Test2. php "erg," POST ");


And here is my PHP program:

<? Php
$ Content = $ _POST ["variable1"];
$ Handle = fopen ("results.txt", "a");
fwrite ($ handle, $ content);
fwrite ($ handle, "|");
fclose ($ handle);
?>

The files are all in the same folder and the return value I will not continue processing.
Hope someone can help me now because I really do not know how to continue...: - /
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

I might be wrong but there is a space in "Test2. php" (between dot and php.

Also a ',' should be between "Test2.php" and erg


And in the php file shouldn't be spaces between $ and the variable name.

Ignore me if I'm wrong.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 448

Post 3+ Months Ago

I agree with stev_ro

with what you posted i can see alot of errors in the code

i wouldn't try to load back into the loadvars object you are sending from.

your code
Quote:
z = 39;
var erg: LoadVars = new LoadVars ();
erg.variable1 = z;
erg.sendandload ("Test2. php "erg," POST ");


ACTIONSCRIPT Code: [ Select ]
var loader = new LoadVars();
loader.onLoad = function(success) {
  if(success) {
   
    // trace the status (variable i made up in the php)
    trace(loader.status);
 
  }
}
 
z = 39;
var sender = new LoadVars();
sender.variable1 = z;
sender.sendAndLoad("test2.php", loader, "post");
 
 
  1. var loader = new LoadVars();
  2. loader.onLoad = function(success) {
  3.   if(success) {
  4.    
  5.     // trace the status (variable i made up in the php)
  6.     trace(loader.status);
  7.  
  8.   }
  9. }
  10.  
  11. z = 39;
  12. var sender = new LoadVars();
  13. sender.variable1 = z;
  14. sender.sendAndLoad("test2.php", loader, "post");
  15.  
  16.  


With the php you have a space in the php tag and well as in between the $ and varibles. you also have Content for content and Handle for handle

Quote:
And here is my PHP program:

<? Php
$ Content = $ _POST ["variable1"];
$ Handle = fopen ("results.txt", "a");
fwrite ($ handle, $ content);
fwrite ($ handle, "|");
fclose ($ handle);
?>


PHP Code: [ Select ]
<?php
$content = $_POST["variable1"];
$handle = fopen ("results.txt", "a");
fwrite($handle, $content);
fwrite($handle, "|");
fclose($handle);
 
// Echo the status
echo 'status=Script Completed';
?>
 
  1. <?php
  2. $content = $_POST["variable1"];
  3. $handle = fopen ("results.txt", "a");
  4. fwrite($handle, $content);
  5. fwrite($handle, "|");
  6. fclose($handle);
  7.  
  8. // Echo the status
  9. echo 'status=Script Completed';
  10. ?>
  11.  


NOTE you should make sure that your server allows fopen shared servers like to lock this down do to security issue

<?php

phpinfo();

?>

this will help you figure that out

----------------------------------

This should get you started in the right direction this is not tested but the visual errors are fixed

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.