Highlighted

swf to PHP to mySQL question

Participant ,
Feb 28, 2020

Copy link to clipboard

Copied

I know this is really old tech but I am still using it!1

 

So I have a test .php page set up by my mySQL guy on let's call it http://ourserver/local/rest/index.php and I need to POST 'abc_request' to it, with  and send a key - {"key":"1234567"}.

 

I have the following code:

AS3:

var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("http://ourserver/local/rest/index.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);

// I a, trying the following ....
phpVars.abc_request;
phpVars.username = 'abc_request';
phpVars.password = 'abc_request';
phpVars.key = "1234567";
phpLoader.load(phpFileRequest);

 

the relevant PHP code is:

 

if(isset($_POST['abc_request'])) {
$abc_request = json_decode($_POST['abc_request'], true);
if(is_array($abc_request) && isset($abc_request['key'])) {
if($abc_request['key']=="1234567") { // key correct
mysql_select_db($database_aquiescedb, $aquiescedb);
$query_rsCourses = "SELECT cid, name FROM courses WHERE publish = 1 ORDER BY name ASC";
$rsCourses = mysql_query($query_rsCourses, $aquiescedb) or die(mysql_error());
if(mysql_num_rows($rsCourses)>0) {
$reponse = array(); 
while ($row_rsCourses = mysql_fetch_assoc($rsCourses)) { 
$reponse['courses'][$row_rsCourses['cid']]['course_name'] = $row_rsCourses['name'];
echo json_encode($reponse); 
mysql_free_result($rsCourses);
die();
} else {
$errors[] = "No data";
}
}
 
currently I am getting:
 
Error opening URL 'http://ourserver/local/rest/index.php?' Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://ourserver/local/rest/index.php
 
I dont know whether this means:
The test .swf just can't see the .php page online ( nb I can see it in a browser)
Or whether it means the code isn't accessing the page because it isn't posting 'abc_request' to the PHP correctly.
 
So I have:
 
Turned on "Local playback security Access network only' in swf publish settings.
 
I am not clear how to POST 'abc_request' to the .PHP in the actionscript code.
 
I am trying to put "abc_request" in the variables but not sure what property of variables it shouldbe . Any help/ advice appreciated.
 
Best Tommy Banana
TOPICS
ActionScript, Code, Other

Views

133

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

swf to PHP to mySQL question

Participant ,
Feb 28, 2020

Copy link to clipboard

Copied

I know this is really old tech but I am still using it!1

 

So I have a test .php page set up by my mySQL guy on let's call it http://ourserver/local/rest/index.php and I need to POST 'abc_request' to it, with  and send a key - {"key":"1234567"}.

 

I have the following code:

AS3:

var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("http://ourserver/local/rest/index.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);

// I a, trying the following ....
phpVars.abc_request;
phpVars.username = 'abc_request';
phpVars.password = 'abc_request';
phpVars.key = "1234567";
phpLoader.load(phpFileRequest);

 

the relevant PHP code is:

 

if(isset($_POST['abc_request'])) {
$abc_request = json_decode($_POST['abc_request'], true);
if(is_array($abc_request) && isset($abc_request['key'])) {
if($abc_request['key']=="1234567") { // key correct
mysql_select_db($database_aquiescedb, $aquiescedb);
$query_rsCourses = "SELECT cid, name FROM courses WHERE publish = 1 ORDER BY name ASC";
$rsCourses = mysql_query($query_rsCourses, $aquiescedb) or die(mysql_error());
if(mysql_num_rows($rsCourses)>0) {
$reponse = array(); 
while ($row_rsCourses = mysql_fetch_assoc($rsCourses)) { 
$reponse['courses'][$row_rsCourses['cid']]['course_name'] = $row_rsCourses['name'];
echo json_encode($reponse); 
mysql_free_result($rsCourses);
die();
} else {
$errors[] = "No data";
}
}
 
currently I am getting:
 
Error opening URL 'http://ourserver/local/rest/index.php?' Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://ourserver/local/rest/index.php
 
I dont know whether this means:
The test .swf just can't see the .php page online ( nb I can see it in a browser)
Or whether it means the code isn't accessing the page because it isn't posting 'abc_request' to the PHP correctly.
 
So I have:
 
Turned on "Local playback security Access network only' in swf publish settings.
 
I am not clear how to POST 'abc_request' to the .PHP in the actionscript code.
 
I am trying to put "abc_request" in the variables but not sure what property of variables it shouldbe . Any help/ advice appreciated.
 
Best Tommy Banana
TOPICS
ActionScript, Code, Other

Views

134

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 28, 2020 0
Participant ,
Feb 28, 2020

Copy link to clipboard

Copied

So - I tried putting the .swf online rather than testing from within anuimate so it doesnt seem to be throwing the IO error now....

  So now to get it to push 'abc_request'

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 28, 2020 0