#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Romania
    Posts
    5
    Rep Power
    0

    win nt 40 + apache::can't read php generated variables into Flash MX


    Hello everybody!
    This is my first message on this forum.
    I have the following problem:
    System:
    Win nt 4.0 service pack 6
    Apache
    PHP
    MySQL
    Flash MX
    The problem:
    reading php generated variables from Flash
    The php script looks like this:


    PHP:--------------------------------------------------------------------------------

    <?
    $result = $HTTP_GET_VARS['input'] +1;
    print "result=$result";
    ?>

    --------------------------------------------------------------------------------

    When I enter in the browser's address window the following address:
    <http://localhost/phpFile?input=100>
    In the Browser window appears:
    <result=101>

    So the php works fine with Apache!
    The next step would be to read the "result" variable into Flash, using the "loadVars()" method.
    This part doesn't work.

    What could be the problem?
    Win NT permissions?
    Apache settings?
    PHP .ini settings?
    I hope that somebody has the answer.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    What could be the problem?
    Win NT permissions?
    Apache settings?
    PHP .ini settings?
    none of the above. maybe you have to send a "\n" at the end of the string.
    i cannot remember, but i succeeded only after some tries too...

    how do you access the variable in flash? Can we have 2 lines of code from you (the line with loadVars() and the line where you want to work with the variable...)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Romania
    Posts
    5
    Rep Power
    0
    I have this code in the first( and only) frame of the .fla file:
    ------------------------------------------------------------------------------
    _global.input=100;
    lvObj=new LoadVars();
    lvObj.input=_global.input;
    lvObjRec=new LoadVars();
    lvObjRec.onLoad=function(){
    _root.result_tf.text=this.result;
    }
    lvObj.sendAndLoad("http://localhost/myFlashPhpTest/process.php" + "?" + lvObj.toString(), lvObjRec);
    stop();
    ------------------------------------------------------------------------------
    note: _root.result_tf is a text field in the same frame.

    My php looks like this:
    -----------------------------------------------------------------------------
    <?
    if(isset($HTTP_GET_VARS['input']))
    {
    $result = $HTTP_GET_VARS['input'] +1;
    print "result=$result\n";
    }
    ?>
    -----------------------------------------------------------------------------

    How must I modify my php file?
    I have attached the files to this message.
    Please test them on your computer.
    Attached Files
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    did they make a new script language for Flash MX? I only have Flash 5, but there is no predefined "LoadVars" object.

    i only have a "loadVariables()" command, that will be used like this:
    Code:
    loadVariables("http://localhost/myFlashPhpTest/process.php?input="+String(_global.input), 0);
    result_tf.text=result;
    ... are you running your flash inside the browser and on the same domain?
    you cannot do cross-domain access nor can you run the file from your harddisk. it has to be loaded from http://localhost too.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    14
    Try using

    $_REQUEST instead of $HTTP_GET_VARS for some reason PHP does not pick up vars sent from Flash in a GET string using HTTP_GET_VARS.

    Its happened to me before.

    M. Hirsch I suggest you pick up MX, the new objects and event handlers blow the socks off 5.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    14
    did they make a new script language for Flash MX? I only have Flash 5, but there is no predefined "LoadVars" object.

    i only have a "loadVariables()" command, that will be used like this:


    code:--------------------------------------------------------------------------------
    loadVariables("http://localhost/myFlashPhpTest/process.php?input="+String(_global.input), 0);
    result_tf.text=result;
    --------------------------------------------------------------------------------

    ... are you running your flash inside the browser and on the same domain?
    you cannot do cross-domain access nor can you run the file from your harddisk. it has to be loaded from http://localhost too.

    M. Hirsch he stated at the top he has Flash MX, most of the stuff you stated can be done in Flash MX including cross-domain stuff. And running it from your harddisk.

    Also your code probably will not work as expected since you need to detect when the variables have been loaded before you can assign the value of one to a text field.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    ok, you convinced me that i need this MX too. On monday iŽll ask my boss

IMN logo majestic logo threadwatch logo seochat tools logo