#1
  1. Metal-Freak
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Kuala Lumpur, Malaysia
    Posts
    45
    Rep Power
    14

    Passing data from php to flash error.


    Can anybody help me with this?

    here's my php code
    Code:
    <?php
    $username="user";
    $password="password
    $database="website";
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT *
    FROM `wp_posts`
    WHERE `ID`
    IN (
    
    SELECT `object_id`
    FROM `wp_term_relationships`
    WHERE `term_taxonomy_id` =1
    OR `term_taxonomy_id` =3
    OR `term_taxonomy_id` =4
    )
    AND `post_status` = 'publish'
    ORDER BY `wp_posts`.`post_date` DESC
    LIMIT 5";
    $result=mysql_query($query) or die( "Query error");
    
    $num=mysql_numrows($result);
    
    mysql_close();
    
    //echo "<b><center>Database Output</center></b><br><br>";
    
    $i=0;
    while ($i < $num) {
    
    $theID=mysql_result($result,$i,"ID");
    $field1=mysql_result($result,$i,"post_author");
    $field2=mysql_result($result,$i,"post_date");
    $field3=mysql_result($result,$i,"post_title");
    $field4=mysql_result($result,$i,"post_status");
    $field5=mysql_result($result,$i,"post_type");
    
    $theResult .= "result$i&$field3&$theID";
    $i++;
    }
    print "results=$theResult";
    ?>
    Here's my actionscript

    Code:
    var loader:URLLoader = new URLLoader();
    loader.dataFormat=URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, completeHandler);
    var request:URLRequest = new URLRequest("test.php");
    request.method=URLRequestMethod.POST;
    var userID:uint;
    var username:String;
    function completeHandler(e:Event):void {
    	var loader:URLLoader = URLLoader(e.target);
    	var vars:URLVariables = new URLVariables(loader.data);
    	Object(root).output_txt= vars.results;	
    }
    
    loader.load(request);
    I keep getting this error
    Code:
    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()
    What in the blue hell is going on?

    While I am at it, how do I break apart strings in AS3? I know in AS2 you can use the String.split function...
    SCUMGRIEF
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    A "URL-encoded query string containing name/value pairs" is the same type of string that you would see in the address bar of your browser, something like: "var1=value1&var2=value2&var3=value3"

    There are certain characters that you cannot use in the value without encoding them; one of those characters is &, since it has special meaning (a variable separate).

    PHP has a urlencode function that you can use to automatically apply the necessary encoding to the value.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo