9 Replies Latest reply on Feb 9, 2007 7:03 AM by duckets

    Getting a return value from PHP to director

    ajeet.ghule Level 1
      Hi All :
      I want to get a return value from my PHP page back to director.Is there any way i can achieve my goal.
      Suppose i have a varible whose value is "XYZ". then i should be alble to get the return value from the PHP page to Director.
      Does director have any command which can access that varaible value.

      Thanks & Regards
        • 1. Re: Getting a return value from PHP to director
          duckets Level 1
          If you use 'postNetText', 'netDone' and 'netTextResult', you should be able to achieve what you want. Look up those commands in the director help.

          Director will recieve the plain text output of your php file, so it's up to you to decided how to parse it (unlike flash's "loadVars" command, which accepts a querystring format).

          A very basic way would be to simply output just the value, and nothing else.
          In director, you could then assign the result to a variable (once you have confirmed the net operation is complete, with 'netdone'), like this:

          myVar = netTextResult(netID)

          Hope this helps!

          - Ben
          • 2. Re: Getting a return value from PHP to director
            ajeet.ghule Level 1
            Hi duckets :
            I wanted to know if i store a varibel in PHP page.Suppose i assign it value in PHP script.Will be able to retrive that value in the director using the above command.


            Thanks
            • 3. Re: Getting a return value from PHP to director
              duckets Level 1
              Yes. You'll have to use 'print' or 'echo' to output the value of that variable when the page is requested by director. Whatever is printed out by the php page is what director will recieve. If you want to just communicate the value of a single variable, you can simply make your php page 'print' the value of the variable, and make director assign the response read by 'netTextResult' into a director variable.

              - Ben
              • 4. Re: Getting a return value from PHP to director
                Level 7

                Just in case you mean the PHP page in which the Director file (.dcr) is
                embedded, you could look into the externalParamCount().

                Look at:
                http://www.shocknet.org.uk/defpage.asp?pageID=4

                for an explanation.

                If you want director to make a new request to a webserver to retrieve
                information, go with Ben's advice.

                HTH,
                Manno

                externalParamCount()

                ajeet.ghule wrote:
                > Hi duckets :
                > I wanted to know if i store a varibel in PHP page.Suppose i assign it value in PHP script.Will be able to retrive that value in the director using the above command.
                >
                >
                > Thanks

                --
                ----------
                Manno Bult
                http://www.aloft.nl
                manno@xs4all.nl
                • 5. Re: Getting a return value from PHP to director
                  Lukewig Level 1
                  Hi,

                  You can also use XML to 'transport' data between Director and PHP (ie the PHP scripts generate XML for Shockwave to read). Have a look at

                  http://www.lingoworkshop.com/Articles/PHP_and_MySQL.php

                  Cheers
                  Luke
                  • 6. Re: Getting a return value from PHP to director
                    ajeet.ghule Level 1
                    Hi Ben :-)

                    I tried with the method which you told for getting the PHP values back into Director.But with no sucess :-(
                    I am really in urgency.

                    what i am doing is passing a query string variable with the director postTextResult command

                    on mouseup me
                    netID = postNetText(" http://localhost//PHPApplications/Querystring.Php", infoList)
                    end

                    but by doing thsi i am just getting the netid which is 1,2,3 etc

                    but in the PHP file i am just printing a variable. that value i should eb able to get.

                    My PHP file cod e is this

                    <?php echo "ABC"; ?>


                    i should be able to get teh value "ABC" in director.
                    Please let me know if i am making sense.






                    Please let me know how do i do this?I am really stuck bacause of this.also if i send the values from director would that php page be able to recieve those values.





                    • 7. Re: Getting a return value from PHP to director
                      duckets Level 1
                      Net operations are not synchronous - that is, after issuing the 'getnettext' or 'postnettext' command, you have to wait for it to complete, and you have to use a special command to check whether it's complete.

                      Once you have your 'netid' number, you need to use this number to check whether the net operation has finished. I suggest, since you are initiating the post request within a button behaviour (the mouseup handler), you could add an 'exitframe' handler to that same button to check whether the operation is complete. See attached code.

                      - Ben

                      (by the way, in my initial reply, I said: "If you use 'postNetText', 'netDone' and 'netTextResult', you should be able to achieve what you want. Look up those commands in the director help", which describes exactly this)
                      • 8. Re: Getting a return value from PHP to director
                        ajeet.ghule Level 1
                        hi I tried your code but with no success
                        May be somethign is going wrong at my end :(
                        but when i run the PHP page in the browser i get to see the value printed on to the page.
                        But when i try to request that page from browser i get netId as some integer value.and check if netdone and then alert the values of the NetId but teh alert box is blank.

                        I not getting what the problem is.I am assignign the value to the variable in PHP and that value is returned as void to me even if i am geeting the netId with some value.
                        • 9. Re: Getting a return value from PHP to director
                          duckets Level 1
                          In that case, perhaps it's a problem with director not playing nice with your 'localhost' setup. Perhaps try 127.0.0.1 instead of 'localhost', or try moving your php files to a remote web server and using a real web url.

                          - Ben