Im using as3, mysql and php, trying to send username and receive (points) and post the points in a text object on the stage, I can send points to the server with similar script but can get numbers back!
// global variables
var loader:URLLoader;
var urlReq:URLRequest;
var urlVars:URLVariables;
var myVars:URLVariables;
addEventListener(Event.ENTER_FRAME, onit);
function onit(e:Event):void
{
urlReq = new URLRequest("http://www.mysite.com/GetPoints.php");
urlReq.method = URLRequestMethod.POST;
urlVars = new URLVariables();
urlReq.data = urlVars;
urlVars.username = nickname_txt.text;
loader = new URLLoader(urlReq);
loader.addEventListener(Event.COMPLETE, onUpdateComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlReq);
}
function onUpdateComplete(e:Event):void
{
myVars = e.target.data;
totalP.text = myVars.total;
}
the php reruns the points when executed in a browser, but not connecting to flash.
<?php
$username = $_POST["username"];
// defining main variables
$dbHost = "localhost";
$dbUser = "";
$dbPass = "";
$dbName = "";
$dbTable = "`".$username."_points`";
@mysql_connect($dbHost, $dbUser, $dbPass) or die(mysql_error());
@mysql_select_db($dbName) or die(mysql_error());
$data = "";
$res = mysql_query("SELECT * FROM ".$dbTable." ORDER BY id") or die(mysql_error());
while($row = mysql_fetch_object($res)) {
$data = "total=".$row->total;
print $data;
}
?>
Any help would be greatly appreciated !