chumps
February 3rd, 2009, 09:38 AM
I have studied this again and again trying to find results. Traced out all the variables before they leave the flash file, and then again when they enter the php. In this space they seem to get lost. I have no idea why this is:
Flash Code and PhP code shown below:
Flash Code:
package {
import flash.display.*;
import flash.net.*;
import flash.events.Event;
public class sendPracticeResults extends Sprite {
public var _totalAttempts:Number;
public var _totalCorrect:Number;
public var _userId:Number;
public var _gameId:Number;
public var resultText:String;
public var urlrequest:URLRequest = new URLRequest( "http://liberation.iwishiwaschucknorris.com/games/php/practiceResults.php" );
public function sendPracticeResults(totalAttempts:Number, totalCorrect:Number, userId:Number, gameId:Number) {
_totalAttempts = totalAttempts;
_totalCorrect = totalCorrect;
_userId = userId;
_gameId = gameId;
var variables:URLVariables = new URLVariables();
variables.attempts = _totalAttempts;
trace("variables.attempts: "+variables.attempts);
variables.correct = _totalCorrect;
variables.userId = _userId;
variables.gameId = _gameId;
urlrequest.method = URLRequestMethod.POST;
urlrequest.data = variables;
sendToURL(urlrequest);
checkResult();
}
private function checkResult() {
var loader:URLLoader = new URLLoader (urlrequest);
loader.addEventListener(Event.COMPLETE, onComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlrequest);
}
private function onComplete (event:Event):void{
var variables:URLVariables = new URLVariables( event.target.data );
resultText = variables.msg;
//_returnText = new resultTangle(""+resultText+"", 100, 60, 0xFF0000, _mainClass);
//addChild(_returnText);
trace(resultText);
}
}
}
PHP code:
<?php
include("connect.inc.php");
$attempts = $_POST['attempts'];
$correct = $_GET['correct'];
$userId = $_GET['userId'];
$gameId = $_GET['gameId'];
echo("Attempts Goes Here".$attempts);
function init() {
if(isset($attempts) && isset($correct) && isset($userId) && isset($gameId)){
insertIntoTable($attempts, $correct, $userId, $gameId);
}
else
{
printOutput("0", "Fail");
}
}//close function
function insertIntoTable($attempts, $correct, $userId, $gameId) {
$sql = "INSERT INTO adding ( Game_ID, game_Type, adding_Score) VALUES ('$gameId', '1', '$correct')";
$result = mysql_query($sql);
if($result) {
printOutput("1", "Score Uploaded");
}
else
{
printOutput("0", "Failed to Upload");
}
}//Close function
function printOutput($code, $msg){
print "par=$code&msg=$msg";
}//close function
init();
?>
any help will be greatly appreciated.
Flash Code and PhP code shown below:
Flash Code:
package {
import flash.display.*;
import flash.net.*;
import flash.events.Event;
public class sendPracticeResults extends Sprite {
public var _totalAttempts:Number;
public var _totalCorrect:Number;
public var _userId:Number;
public var _gameId:Number;
public var resultText:String;
public var urlrequest:URLRequest = new URLRequest( "http://liberation.iwishiwaschucknorris.com/games/php/practiceResults.php" );
public function sendPracticeResults(totalAttempts:Number, totalCorrect:Number, userId:Number, gameId:Number) {
_totalAttempts = totalAttempts;
_totalCorrect = totalCorrect;
_userId = userId;
_gameId = gameId;
var variables:URLVariables = new URLVariables();
variables.attempts = _totalAttempts;
trace("variables.attempts: "+variables.attempts);
variables.correct = _totalCorrect;
variables.userId = _userId;
variables.gameId = _gameId;
urlrequest.method = URLRequestMethod.POST;
urlrequest.data = variables;
sendToURL(urlrequest);
checkResult();
}
private function checkResult() {
var loader:URLLoader = new URLLoader (urlrequest);
loader.addEventListener(Event.COMPLETE, onComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlrequest);
}
private function onComplete (event:Event):void{
var variables:URLVariables = new URLVariables( event.target.data );
resultText = variables.msg;
//_returnText = new resultTangle(""+resultText+"", 100, 60, 0xFF0000, _mainClass);
//addChild(_returnText);
trace(resultText);
}
}
}
PHP code:
<?php
include("connect.inc.php");
$attempts = $_POST['attempts'];
$correct = $_GET['correct'];
$userId = $_GET['userId'];
$gameId = $_GET['gameId'];
echo("Attempts Goes Here".$attempts);
function init() {
if(isset($attempts) && isset($correct) && isset($userId) && isset($gameId)){
insertIntoTable($attempts, $correct, $userId, $gameId);
}
else
{
printOutput("0", "Fail");
}
}//close function
function insertIntoTable($attempts, $correct, $userId, $gameId) {
$sql = "INSERT INTO adding ( Game_ID, game_Type, adding_Score) VALUES ('$gameId', '1', '$correct')";
$result = mysql_query($sql);
if($result) {
printOutput("1", "Score Uploaded");
}
else
{
printOutput("0", "Failed to Upload");
}
}//Close function
function printOutput($code, $msg){
print "par=$code&msg=$msg";
}//close function
init();
?>
any help will be greatly appreciated.