1

Ive made a query in PHP, and I'm trying to send the results back into Flash via AS3, but it's throwing up this error...

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete()

Here is the relevant part of the PHP and AS3 code, including the query. The Flash variable rssAdd is passed over to the PHP which is using it in the PHP query accordingly.

$url = $_POST['rssAdd'];
$query= SELECT title
FROM Feed
WHERE category = (SELECT category
FROM Feed
WHERE url =$url) AND url!=$url;
$result = mysql_query($query);
echo  $query;

Here is the AS3 code I've done so far.

function recommendation(){

var request:URLRequest = new URLRequest("url");
request.method = URLRequestMethod.POST

var recVars:URLVariables = new URLVariables();

recVars.rssAdd=rssAdd;
request.data = recVars

var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, onComplete);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(request);

function onComplete(event:Event):void{
recommend.text = event.target.data;
}
 } 

Any help would be most appreciated, thanks.

3
  • 1
    Are you wrapping your SQL instruction ($query) with quotes? Commented Apr 23, 2010 at 20:31
  • no, I hadnt, thanks. It compiles now, although nothing is shown in the text box, when there should be a result. (i tested the query in HeidiSql, replacing $url, with the url that should be held in rssAdd, and there is a result.) Commented Apr 23, 2010 at 21:00
  • I'd say it parses fine now, rather than compiles :P Commented Aug 2, 2010 at 0:10

2 Answers 2

1

Have you checked what is coming back from the server running your PHP application? Checking the details of the request and the response, using Firefox and the Net panel of Firebug, could shed light on some other unexpected problem with the web server.

Sign up to request clarification or add additional context in comments.

9 Comments

The response from the PHP file is the query itself, the same response i get if I trace event.target.data.title in flash. Does that shed any more light on my problem? thanks.
Not quite sure what you mean. The variable rssAdd is a String, containing a url.
In your onComplete() handler you have a variable called "recommend". What class is it and where was it declared (or was it dragged onto the stage in the IDE)? This could be a scope problem - first check that Publish Settings -> Flash -> Settings -> Strict Mode is checked. Also try moving onComplete() out of recommendation(). Rename it if necessary.
Also try changing "loader.dataFormat = URLLoaderDataFormat.VARIABLES;" to "loader.dataFormat = URLLoaderDataFormat.TEXT;"
Oh I see, its text using the text tool. Its finding onComplete, since I put the trace in there.
|
1

Fixed it with the following return:

$result = mysql_query($query);
$row=mysql_fetch_array($result);
print ("recTitle=".urlencode($row['title']));

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.