SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Flash php help

  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    england
    Posts
    328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Flash php help

    hi
    iam trying to get infomation from php to a textfield in flash, i can get the output from php to flash no problem but all the output is showing in one textfield.
    i have to texfields username, email, can't seem to get the username to appear in the username texfield and the email into the email textfiels, they both appear in the username textfield.
    here is the code.

    Code:
    var request:URLRequest = new URLRequest("dataLayer.php");
    			request.method = URLRequestMethod.GET;
    			
    			var loader:URLLoader = new URLLoader();
    			loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    			loader.addEventListener(Event.COMPLETE, completeHandler);
    
    			loader.load(request);
    			
    			function completeHandler(evt:Event) {
    				
    				var username = evt.target.data.username;
    				
    				username_txt.text = username;
    				
        var email = evt.target.data.email;
    				
    				email_txt.text = email;
    				
    				
    				
    			}

    php code

    PHP Code:
    $query sprintf("SELECT username,email FROM users_tbl where username ='$myusername'and approved = 1  ",
        
    mysql_real_escape_string($username));
     
    // Perform Query
    $result mysql_query($query);

    // Check result
    // This shows the actual query sent to MySQL, and the error. Useful for debugging.
    if (!$result) {
        
    $message  'Invalid query: ' mysql_error() . "\n";
        
    $message .= 'Whole query: ' $query;
        die(
    $message);
    }

    // Use result
    // Attempting to print $result won't allow access to information in the resource
    // One of the mysql result functions must be used
    // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
     
      
     
    while ($row mysql_fetch_assoc($result)) {
     
    $myusername$row['username'];
         
    $email$row['email'];               
                       
        
    }

        
    // send the data to Flash using the URL encoded format
        
    echo "username=".urlencode($myusername);

        echo 
    "email=".urlencode($email);
        
    mysql_free_result($result);
    ?> 
    please help

  2. #2
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting an ampersand (&) in front of the variable name "email" when you print it out so Flash knows a new var is starting. Like so:

    Code PHP:
    echo "&email=".urlencode($email);

  3. #3
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,518
    Mentioned
    37 Post(s)
    Tagged
    1 Thread(s)
    ..
    Last edited by EastCoast; Oct 5, 2009 at 14:16. Reason: didnt notice chris had already posted


Bookmarks

Posting Permissions

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