7 Replies Latest reply on Dec 3, 2007 12:53 AM by Greg Dove

    flash -> php -> mysql

    NickTheNameless Level 1
      i have my flash movie which send data via loadVars to a php that puts it into a mysql database. the connection is working, but not sending the data. after i run this actionscript function, new rows are added to my database, they just don't contain any information.

      all relevant code is posted below. any help, suggestions, ideas, or thoughts would be much appreciated.... thanks!

      by the way, i almost posted an export of my database, but it has a lot of columns (many more than are seen here). i can post it's contents if you think it will help, but my take on it is.... the problem is sending data to from flash to php, not from php to mysql. right?

        • 1. Re: flash -> php -> mysql
          NickTheNameless Level 1
          well i found one problem. my AS was using the post method while my php was looking via for get. so i fixed that, my AS is now using the get method and the data is transferred into the database. it actually looks like it working now....

          however, i'm still getting a unsuccessful serverResponse because my dynamic text field displays "there has been an error submitting your request". what's wrong?
          • 2. Re: flash -> php -> mysql
            Greg Dove Level 4
            I'm no php expert, but I can't see a print or echo there for a response to be returned to flash.

            return $result;

            seems unusual (at least to me, coming from an actionscript world, anyway) because its not inside a function. I checked the php docs and its legal in global scope but does this:
            "If called from the global scope, then execution of the current script file is ended..."

            So its possible your

            is not executing as well.

            I think you need to print or echo something (e.g. "&result=OK&") instead of using the return.

            • 3. Re: flash -> php -> mysql
              NickTheNameless Level 1
              well you can't say it's not healthy to talk to yourself. i don't know what it is about posting, it makes me get the answer, whether from my own head or someone else's.

              anyweezer, i was using sendAndLoad, which sends data to my php, but also expects a response. if it doesn't get a response, flash is going to assume it's communication attempt was unsuccessful. the problem was in my php, it wasn't giving any kind of response for flash to read. if i add...

              echo "allocationSubmitted=true";

              it works just fine. i could put anything really, but i decided to create a variable that would fit the syntax of the surrounding code and use it in flash in an if statement.
              • 4. Re: flash -> php -> mysql
                NickTheNameless Level 1
                ha ha, we posted at the same time :)
                • 5. Re: flash -> php -> mysql
                  Greg Dove Level 4
                  Yep. Great to see you got it sorted. I'm curious about the return statement though? What do you think?
                  • 6. Re: flash -> php -> mysql
                    NickTheNameless Level 1
                    you know i'm not sure really. before when i posted i put my echo statement after the return. that change made it register in flash because it was now getting a response from the server, so i guess the return didn't end the execution of the script file (as php.net says it does).

                    i am taking the return statement out, the only reason it was in there was because i copied, pasted and edited previously used code of mine (i play with too many different languages... i have to do that). after i took out the return the only difference i can see is that bringing up the file in a browser directly, it displays "allocationSubmitted=true", whereas before it didn't display anything.

                    it still gets me to wonder though, how does that echo statement work after that return statement?
                    • 7. Re: flash -> php -> mysql
                      Greg Dove Level 4
                      I don't know about the php return statement. I just checked the php docs as well and that's why I asked. It wouldn't be the first time some docs incorrectly described the behaviour of a programming language or perhaps its not behaving as documented because it has a return value associated.
                      Either way , were it me, I would remove it too, I can't see it doing anything useful in that context.