views:

255

answers:

2

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  A: 

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"])
Sbm007
A: 

Thank you for taking the time to respond. Especially thank you for pointing out how to escapte SQL query from injections.

I'm a complete noob where MySQL is concerned but I did find a tutorial that shows how to use the $_Post that I will work through.

Again, thanks. Annie

Annette B
No problem, glad I could help :)
Sbm007