# Variable value from flash to php

**URL:** <https://forum.kirupa.com/t/variable-value-from-flash-to-php/279811>\
**Category:** Uncategorized\
**Created:** [January 19, 2009, 4:50pm UTC](https://forum.kirupa.com/t/variable-value-from-flash-to-php/279811 "2009-01-19T16:50:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattiasA](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@MattiasA](https://forum.kirupa.com/u/MattiasA)\
**Post date:** [January 19, 2009, 4:50pm UTC](https://forum.kirupa.com/t/variable-value-from-flash-to-php/279811/1 "2009-01-19T16:50:21Z")

</div>

Hi

I have been able to get this code to work!:

on (release) {  
var time = getTimer();  
for (var i = 0; i\<1000; i++) {  
var j = i;  
}  
\_root.mb.onRelease = function() {  
/\* Contact PHP File _/  
SendVars = new LoadVars();  
targetObject = new LoadVars();  
SendVars.SendData = \_root.text1writer.text;  
SendVars.allowSend = true;  
SendVars.myFile = “CreateMe.txt”;  
targetObject.onLoad = function(success:Boolean) {  
if (success) {  
/_ Success _/  
trace(“Successfully received notification from the PHP File.”);  
} else {  
/_ Failure \*/  
trace(“Failed to receive notification from the PHP File.”);  
}  
};  
SendVars.sendAndLoad(“[http://localhost/](http://localhost/) **/**.php?uniqueID=” + getTimer(), targetObject, “POST”);  
};

The PHP script looks like this!:

\<?php  
$myFile = $\_POST[‘myFile’];  
$allowSend = $\_POST[‘allowSend’];  
$SendData = $\_POST[‘SendData’];  
if ($allowSend == true){  
$fh = fopen($myFile, ‘w’) or die(“can’t open file”);  
fwrite($fh, $SendData);  
fclose($fh);  
echo “result=success”;  
}  
?\>

The result when i push the button named mb is that the text that was written in the text1writer textarea gets printed into the the textfile named CreateMe.

So far so god. But what I am really looking to do is this:

I want the value of a variable to be printed in the textfile (or even better in a mySQL database). The variable value I want to post is from the varable:

var time = getTimer();

so the value should be a number.

So my question is. How do I change the code to make this happen?

I am guessing that SendVars.SendData = \_root.text1writer.text; should be replaced with something else, but what?

I noticed that there is the codes: value an valueOf. Is this something I can use?

How wrong is this?: SendVars.SendData = time\_var.valueOf;
