DrGonzo1208
03-05-2008, 03:35 PM
Hi there,
I've got a flash application that holds a large amount of variabes that I want to add to the database. I currently have it sending data via sendAndLoad (POST) to a php file that then writes the variables to a txt file. i.e:
Flash code
var myVars:LoadVars = new LoadVars();
myVars.onLoad = function():Void {
if (myVars.verify == "success") {
status_txt.text = "save successful";
} else {
status_txt.text = "save failed";
}
};
saveButton.onPress = function() {
myVars.productName = productName_txt.text;
myVars.productCode = productCode_txt.text;
myVars.productColour = productColour_txt.text;
myVars.productGroup = productGroup_txt.text;
myVars.sizeRange = sizeRange_txt.text;
myVars.colourRange = colourRange_txt.text;
myVars.sendAndLoad("writeToFile.php", myVars, "POST");
}
php script
<?php
$productName = $_POST['productName'];
$productCode = $_POST['productCode'];
$productColour = $_POST['productColour'];
$productGroup = $_POST['productGroup'];
$sizeRange = $_POST['sizeRange'];
$colourRange = $_POST['colourRange'];
$designName = $_POST['designName'];
$filename = $designName;
$data = "&productName=".$productName."&\n"
."&productCode=".$productCode."&\n"
."&productColour=".$productColour."&\n"
."&productGroup=".$productGroup."&\n"
."&sizeRange=".$sizeRange."&\n"
."&colourRange=".$colourRange."&";
$open = fopen($filename.'.txt', 'a');
$write = fwrite($open, $data);
if($write)
{
echo "&verify=success&";
}
else
{
echo "&verify=fail&";
}
?>
The above code works just fine for writing the data to a txt file, but ultimately I'd like to find a way to send these variables to a MySQL database. At the moment i'm just trying to echo or print the _POST array as a test. I can't even echo one variable from the _POST data (i.e echo "$productCode";...
If anyone can see what might be wrong - I would be most greatful...
Thanks.
I've got a flash application that holds a large amount of variabes that I want to add to the database. I currently have it sending data via sendAndLoad (POST) to a php file that then writes the variables to a txt file. i.e:
Flash code
var myVars:LoadVars = new LoadVars();
myVars.onLoad = function():Void {
if (myVars.verify == "success") {
status_txt.text = "save successful";
} else {
status_txt.text = "save failed";
}
};
saveButton.onPress = function() {
myVars.productName = productName_txt.text;
myVars.productCode = productCode_txt.text;
myVars.productColour = productColour_txt.text;
myVars.productGroup = productGroup_txt.text;
myVars.sizeRange = sizeRange_txt.text;
myVars.colourRange = colourRange_txt.text;
myVars.sendAndLoad("writeToFile.php", myVars, "POST");
}
php script
<?php
$productName = $_POST['productName'];
$productCode = $_POST['productCode'];
$productColour = $_POST['productColour'];
$productGroup = $_POST['productGroup'];
$sizeRange = $_POST['sizeRange'];
$colourRange = $_POST['colourRange'];
$designName = $_POST['designName'];
$filename = $designName;
$data = "&productName=".$productName."&\n"
."&productCode=".$productCode."&\n"
."&productColour=".$productColour."&\n"
."&productGroup=".$productGroup."&\n"
."&sizeRange=".$sizeRange."&\n"
."&colourRange=".$colourRange."&";
$open = fopen($filename.'.txt', 'a');
$write = fwrite($open, $data);
if($write)
{
echo "&verify=success&";
}
else
{
echo "&verify=fail&";
}
?>
The above code works just fine for writing the data to a txt file, but ultimately I'd like to find a way to send these variables to a MySQL database. At the moment i'm just trying to echo or print the _POST array as a test. I can't even echo one variable from the _POST data (i.e echo "$productCode";...
If anyone can see what might be wrong - I would be most greatful...
Thanks.