0

Want to send in State, City, County variables from Flash to PHP page:

function retrieve() {

 var scriptRequest:URLRequest = new URLRequest("http://localhost:8080/GSM/KJVold.php");
 var scriptLoader:URLLoader = new URLLoader();
 var scriptVars:URLVariables = new URLVariables();

 scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
 scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);

 scriptVars.State = this.whichState;
 scriptVars.City = this.whichCity;
 scriptVars.County = this.whichCounty;

 scriptRequest.method = URLRequestMethod.POST;
 scriptRequest.data = scriptVars;

 scriptLoader.load(scriptRequest);

 function handleLoadSuccessful($evt:Event):void
 {
 MovieClip(parent).info_txt.text = scriptRequest;

 }

My PHP page reads:

//connection to database stuff

$result = mysql_query("SELECT info FROM kjvold WHERE State='$State' AND City='$City' AND 

County='$County'");

while($row = mysql_fetch_array($result))
{
print "info = " . $row['info'];
}

When I trace actionscipt variables I see named pairs going to page. When I hard code PHP page I can see the right output, but when trying to use variables to PHP in the text box I get object URLRequest not the County info I'm seeking. It sure would help if someone can help me with this. Thanks in advance, Annie.

1 Answer 1

1

I've never used ActionScript before but in your PHP script instead of

$County
$State 
$City

I'm quite sure you need to use

$_POST["County"]
$_POST["State"]
$_POST["City"]

Also it might be an idea to escape your SQL query from injections or other invalid inputs by wrapping the variable in a mysql_real_escape_string() function

Ie:

$_POST["County"]

Becomes:

mysql_real_escape_string($_POST["County"])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.