Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 5 of 5

Thread: Flash & PHP IE problem?

  1. #1

    Flash & PHP IE problem?

    I've got a basic login and registration system built in flash which communicates with an sql database by sending variables to PHP using LoadVars and the sendAndLoad method. I've finally got it working perfectly, but for some reason only in firefox.

    In IE it seems to fail to read in any PHP. For example in firefox logging in would display a wait message in flash, and the status bar would read "waiting for http://..." etc before logging in successfully. In IE the flash wait message would appear indefinitely and the status bar would just display "done" without any activity.

    Is there any reason why a flash file will work perfectly in Firefox and not IE, and if so is this a common problem? If not please let me know and i will post up my code to see if anyone can figure out the problem here.

    Many thanks in advance.

  2. #2
    Hi in my expirience there is a problem with the callback functions of loadvars and sendandload in some browsers. They are not allways called.
    My solution on this problem:

    make a variable at the end of your php file that you send to flash:
    &php_ready='true';

    in your flash start a timer function before you call your php file and set php_ready=null

    in the timer function check if( php_ready )
    when it is your phpfile is processed.

    oh there's also a problem with refreshing your phpdata when using GET so use POST or send a dummy variable with your call that has a random value. especially ie otherwise will take the phpdata from cash...

    I know it's a bit of a workaround but it works in every browser...
    Last edited by borrob; March 16th, 2007 at 03:50 AM.

  3. #3
    Quote Originally Posted by borrob View Post
    Hi in my expirience there is a problem with the callback functions of loadvars and sendandload in some browsers. They are not allways called.
    My solution on this problem:

    make a variable at the end of your php file that you send to flash:
    &php_ready='true';

    in your flash start a timer function before you call your php file and set php_ready=null

    in the timer function check if( php_ready )
    when it is your phpfile is processed.

    oh there's also a problem with refreshing your phpdata when using GET so use POST or send a dummy variable with your call that has a random value. especially ie otherwise will take the phpdata from cash...

    I know it's a bit of a workaround but it works in every browser...
    Hi thanks for your reply.

    I'm already utilising a php variable check system similar to what you suggested, where i detect if the variable 'loginSuccess' is true before proceeding as in the code below.

    /////////////////////////////////////////////////////////////////////////////////
    var loginVars_lv:LoadVars = new LoadVars();
    loginVars_lv.onLoad = function(success) {
    if (success) {
    //if variables load set currentUser number & go to homepage
    if (loginVars_lv.loginSuccess == "true") {
    _root.currentUserNum = loginVars_lv.currentUser;
    gotoAndStop("home");
    //complete login
    } else {
    trace(loginVars_lv.loginSuccess);
    loginstatus = "Sorry, there was a problem with your login, please try again.";
    }
    } else {
    loginstatus = "Sorry, there was an error connecting to the server, please try again.";
    }
    };
    //declare variables to send to PHP
    loginVars_lv.username = loginusername_txt.text;
    loginVars_lv.password = loginpassword_txt.text;
    //send and load variables
    loginVars_lv.sendAndLoad("login.php", loginVars_lv, "POST");
    } else {
    loginstatus = "One or more fields are incorrect, please try again.";
    }
    };
    ////////////////////////////////////////////////////////////

    my php code is as below:

    //////////////////////////////////////////////////////////
    $query = "SELECT * FROM Members WHERE username = '$login_username' AND userpass = '$login_password'";
    $result = mysql_query( $query ) or die ("didn't query");

    //see if there's a single match
    $num = mysql_num_rows( $result );
    if ($num == 1){
    //make array from row, extract array into variables
    while ($row = mysql_fetch_array($result, MYSQL_BOTH))
    {
    extract($row);
    }
    //send variables to flash
    echo "&loginSuccess=true&currentUser=$userID";

    }
    //show error if no match
    else {
    echo "&loginSuccess=false";
    }
    ////////////////////////////////////////////////////////////

    I'm already using "POST" for sending my variables.

    Thanks in advance again.

  4. #4
    yeah this is what i used to do. But the problem here is the callback function:
    loginVars_lv.onLoad = function(success)

    because in some browsers this function is not called i use my workaround and
    use:

    Setinterval to start a timer function to check for the value of
    loginSuccess after i set it to null
    in this way you will get a signal in flash when it is set.
    Maybe there are other solutions out there but this did it for me and i'm using this for several years now whithout problems.
    My timer interval is very short like 10 miliseconds. In the timerfunction i first close it and start it up again when loginSuccess is null.

  5. #5
    Thanks alot i finally managed to sort it out. Bit of a long workaround but what can you do eh?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012