After some researching, it seems this is a pretty popular problem. Unfortunately, none of the previously-answered questions have been able to solve this particular issue I am facing.
So, first things first, The Setup:
Now with that being said, here is The Code.
Note that I have changed the url in the code below to point to a bogus web-server. I have also changed the database connection information to be similarly bogus. The rest of the structure is correct, however, including folder-structure and file-name:
Flash (Code.DataTransmitter):
public function SendData():void {
var myData:URLVariables = new URLVariables();
myData.update = "true";
myData.score_humans = MasterManager.gameManager.scoreHumans;
myData.score_creatures = MasterManager.gameManager.scoreCreatures;
var myRequest:URLRequest = new URLRequest("http://not-a-real-web-server.com/data/testgame.php");
myRequest.data = myData;
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, OnSendDataComplete);
try {
loader.load(myRequest);
} catch (error:Error) {
trace ('Error: unable to load the document.');
}
}
public function OnSendDataComplete(e:Event):void {
}
PHP:
<?php
if (isset($_POST['update'])) {
$dbhost = 'xxx.xxx.xxx.xxx';
$dbuser = 'bogususer';
$dbpass = 'boguspassword';
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, 'test_game_table', 3306);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$score_humans = intval( $_POST['score_humans'] );
$score_creatures = intval( $_POST['score_creatures'] );
if ($score_humans >= 0 && $score_creatures >= 0) { // Error-check: No negative values
$strquery = "update stats";
$strquery .= " set score_humans = score_humans + " . $score_humans;
$strquery .= ", score_creatures = score_creatures + " . score_creatures;
$strquery .= " where id = 1";
$strquery = $mysqli->real_escape_string($strquery); // Even though it should be clean, sanitize it anyways.
$mysqli->query($strquery);
echo "received=true";
}
}
echo "Hello there!";
?>
And now, finally, The Problem.
It's really a simple problem, that probably doesn't deserve this much preamble, but I believe in getting all of the information out and disambiguated first, to reduce the amount of questions needed before solutions can be proposed.
Put more concisely, the request only seems to work correctly when sent through Flash Professional - when sent through Google Chrome, it fails in some capacity.
I would really appreciate any assistance in solving this problem.
Thank you in advance!