A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS3 to PHP and back again

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Location
    New Mexico
    Posts
    101

    AS3 to PHP and back again

    I have a as3 file where I am sending data to a php page, the php checks for the users login information from the database and displays either true or false response. I am getting a wierd %0A%0AlogError=true in the results of the as3 coming from php.

    Here are the code snippets:
    PHP Code:
    <?php
    $name 
    $_POST['fullName'];
    $email $_POST['loginEmail'];

    //Database and sql statements
    //Query database
    //Save query in $result

    if(!mysql_num_rows($result)){
        echo 
    "logError=true";
    }else{
        echo 
    "logError=false";
    }
    ?>
    Code:
    //saving to MovieClip(root) for use in the fla (this is a MC that pops up if the user is not loged in to the system.
    MovieClip(root).loginName = firstName.text + " " + lastName.text;
    MovieClip(root).emailAddress = email.text;
    //send variables to php script and retrieve reply
    var requestIt:URLRequest = new URLRequest ("http://www.myDomain.com/myPage.php");
    requestIt.method = URLRequestMethod.POST; 
    var sendTo:URLVariables = new URLVariables(); 
    sendTo.fullName = MovieClip(root).loginName;
    sendTo.loginEmail = MovieClip(root).emailAddress;
    requestIt.data = sendTo; 
    			
    var loadIt:URLLoader = new URLLoader (requestIt);
    loadIt.addEventListener(Event.COMPLETE, checkIt);
    loadIt.dataFormat = URLLoaderDataFormat.VARIABLES;
    loadIt.load(requestIt);
    							
    					
    function checkIt (event:Event):void{
    	scriptResult = event.target.data;
    	trace(scriptResult);
    }
    Thanks in advance
    BeyondFlash
    Beyond Flash
    Your one stop web shop
    http://www.beyondflash.net

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    PHP is adding some weird whitespace - probably a curl thing? If you can't get rid of that on the server side you could switch your loader over to the string dataformat and pull that little bit of weirdness off manually:

    PHP Code:
    var rawResult:String '%0A%0AlogError=true';
    while(
    rawResult.indexOf('%0A') == 0rawResult rawResult.substring(3);
    var 
    u:URLVariables = new URLVariables(rawResult);
    trace(u.logError); 
    Please use [php] or [code] tags, and mark your threads resolved 8)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center