URLVariables.decode() error when converting to variables
Hello!
I am passing a simple string from a PHP file, that looks like this
PHP Code:
$connect = mysql_connect("localhost", "root", "");
mysql_select_db("dev", $connect);
$result = mysql_query("SELECT * FROM users");
$cant = 0;
while($row=mysql_fetch_array($result)){
echo "Name$cant=$row[name]&Email$cant=$row[email]&";
$cant++;
}
PHP output:
Name0=jane doe&Email0=jane@huj.com&Name1=jane doe&Email1=jane@huj.com&Name2=jane doe&Email2=jane@huj.com&Name3=jane doe&Email3=jane@huj.com&Name4=jane doe&Email4=jane@huj.com&
I am asking flash to prase this data and display each field in a text field, it seems as it is failing at the myTextLoader.dataFormat = URLLoaderDataFormat.VARIABLES; because when i take it out or switch the dataFormat to TEXT, it does not produce that error
Flash Code:
var myTextLoader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://localhost/flash.php");
myTextLoader.load(request);
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
myTextLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
function onLoaded(e:Event):void {
for (var i:Number = 0; i < 9; i++) {
//array for text fields
var nameField:TextField = new TextField();
var emailField:TextField = new TextField();
nameField.text = myTextLoader.data["Name" + i];
emailField.text = myTextLoader.data["Email" + i];
emailField.y += 50;
emailField.x = 200;
nameField.y += 50;
nameField.x = 150;
addChild(nameField);
addChild(emailField);
}
}
Flash 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()
Any Suggestion as to what needs to be changed in order for it to work, i tried to trace stuff, change the variable scope etc.
Read up on this online at Flash Docs, but it seems as though the syntax is correct
Thank you