dcsimg
A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 46

Thread: 'Tutorial on How to use PHP/mySQL interactions

  1. #21
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    I wonder whether your server allows you to create databases, or whether you're tied to the ones already there? Try the command 'show databases' and see what databases already exist. Try to create a table within an existing database as a test.

    If you use an existing one, the only thing is that you'd have to change some references to 'usertrack' in the PHP script above.

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  2. #22
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    hey thanks for the tutorial, I completed most of it, (had to make database using cpannel though). Now Im experimenting with some stuff. First of all I made a php script that send info to the database. it has the $data=$_POST['data] in it and then some other stuff. So I made a flash with a variable called data. Now how do I execute the php script? Do I just say root.load.'phpscript' or watever? Please help.
    BC

  3. #23
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Well. What do you know !

    I just rebuilt another PC as a PHP and mySQL server, so decided to test the tutorial again, and apart from PHP/mySQL installation problems, the tutorial worked OK. Now that I've tested it, has anyone else had any luck, or does anyone need help?

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  4. #24
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Quote Originally Posted by ConnELITE
    hey thanks for the tutorial, I completed most of it, (had to make database using cpannel though). Now Im experimenting with some stuff. First of all I made a php script that send info to the database. it has the $data=$_POST['data] in it and then some other stuff. So I made a flash with a variable called data. Now how do I execute the php script? Do I just say root.load.'phpscript' or watever? Please help.
    Hi,

    The syntax in 3DFA is :

    root.loadVariables ("phpsript.php","POST");

    This will post the existing variables from swf into the PHP script, and a few seconds later, the PHP script will return any variables back into the swf file.

    Be careful however:
    Depending on how your PHP server is set up, it may not allow you to access the variables directly. (If Global variables are turned off on the PHP server as a security precaution). In this case, your PHP script needs to start off with: $variablenameinPHP = $_POST['variablenamefromswf'];

    To bring the variables back from PHP, have the PHP write some text at the end like: echo "&variablenameiwanttoseebackinswf=".$variablenamef romPHP."&";

    A few seconds after the loadVariables command is executed, you'll then get a value in the swf for 'variablenameiwanttoseebackinswf'.



    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  5. #25
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    All,

    Just a note to let you know that this tutorial does not currently work in the new version 4.6 beta 3. If anyone can work out why, then I'll be eternally grateful !

    If it helps, then I think it has something to do with variables being handled differently.

    Cheers,

    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  6. #26
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    I haven't tried this specific tutorial in the new version, but all of my games with sql/php interaction still work. It doesn't work in the preview menu if that's what you mean. Also, sql was recently updated and you might have to ask your host to take off the extra protection they added.
    BC

  7. #27
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Hiya Brent,

    This kind of movie never works in the preview mode, so that isn't really the issue. The old versions still work on the same server, and I haven't updated mySQL, so I know it has to be something to do with the new version. There are a couple of other indicators that suggest it's something to do with handling of variables though, so I'll keep working on it. I generally hold all my variables as root.variable but it seems this doesn't work quite the same as it used to.

    I guess I must have used sloppy programming originally, and I'm suffering from it now

    A simple example of the problem might be the fact that the help button at the top right no longer works. (ie. When you click the help button, no text appears). Also, the scroll bars don't seem to work anymore. Taking them off seems to help some issues, but not the actually loadVariables one. I'll keep working on it though, and hopefully provide an updated version shortly.

    Cheers,

    Morgan
    Please note that my domain has changed to http://www.morganmultinational.com

  8. #28
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    oh yeh, now that you mention it, I noticed that I could'nt get one of my old movies to work. I haven't noticed anything wrong with the root. It may have something to do with your functions Ian. After you taught me enough, I kind of developed my own style and have removed the waiting and sending functions and replaced it with scripts that depend on the php more then the flash. Maybe check those.

    Also, do your movies work when exported in the old 3dfa? Maybe it has something to do with the flashplayer update.
    BC

  9. #29
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Thanks for the pointer. I'll take a look at the functions later although the problem with the helptext shouldn't depend on any functions, so I still think it's a variable handling issue.

    Although the movie does grind very slowly in the new player, if I export with the old version, it does still work in the new player, so although it may be related, I don't think that's the whole problem.

    On a positive note, the new functionality with loadVars where you can monitor whether the variables have been loaded yet, should make this kind of movie much more efficient and more robust in the long run.

    Fingers crossed I'll work it out soon.

    Cheers,

    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  10. #30
    Member
    Join Date
    Jul 2006
    Posts
    56
    Suppose I had the variable score and topscore in a movie.
    If score > topscore, can I POST the topscore to a file?

  11. #31
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    You certainly can. That's exactly the principle in my 10 pin bowling game and darts games. It's just a question of carefully writing the SQL statements you want to run.

    If you manage to get through the tutorial and have understood the principles, then give me a shout if you need some help with the fine details.

    Cheers,

    Morgan.
    Last edited by ForumNewbie; 09-03-2006 at 04:44 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

  12. #32
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Hiya Folks,

    Just a note to let you know that the SQL Console has now been rewritten to work with the latest version of 3DFA. (Version 4.6)

    I've made a few enhancements to it as well, so that it works a bit more efficiently, and added a 'debug' button for looking into errors more easily whilst getting things started. There is a new php script present in the zip file attached to this thread, so be sure to use this with the new version.

    Also, I have worked out how to set SQL security permissions now, so I have set up a dedicated user ID on my SQL server in case anyone wants to play with my hosted example movie. The user ID is called 3dfa, the password is 3dfa and the only database it is allowed to access is also called 3dfa. You should have access rights to do anything in this except change user permissions.

    Feel free to try this, and let me know if you experience any problems.

    If anyone needs the old version for any reason, drop me a PM.

    Best regards,

    Morgan.
    Last edited by ForumNewbie; 09-03-2006 at 04:47 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

  13. #33
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Out of interest, has anyone tried this tutorial in any of the new versions?

    I've been a bit busy recently, but plan to check and update this tutorial soon.

    Cheers,

    M.
    Please note that my domain has changed to http://www.morganmultinational.com

  14. #34
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    I haven't tried this specific tutorial but I was able to get php connections working fine in 4.9.1 I think it was. I would really doubt that the movie in this forum would work though. I have had really bad compatibility issues with old php movies but I oculd never really isolate why. Are you having any troubles? I'm pretty busy with xml socket, but otherwise I would test it.
    BC

  15. #35
    Member
    Join Date
    Nov 2002
    Posts
    67
    I am curious if anybody had any luck with getting data from an sql database, into a flash movie, via a php script, with the latest version of 3D Flash?

    My php script does return my information as can be seen by clicking the below link.

    http://www.carbonst.com/yahtzee1.php

    What would be the syntax to load these into a movie?

    The latest version's helpfile shows:

    my_vars = new LoadVars;
    my_vars.load ("url");

    Then below that example it shows:

    load (url)

    The top example shows "" around the url and the bottom example does not. The top example shows a ; after the command, but the bottom example does not have the ;

    I have tried both examples with no luck. But that does not mean that I am not doing something else wrong. :-)

    I was just curious if anybody has gotten the variables into a movie with the latest version and if so, with what syntax.

    Thanks in advance,
    Phil

  16. #36
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    473
    Try using loadVariables(url, method). The syntax for that is something like...

    loadVariables ("http://www.carbonst.com/yahtzee1.php", "POST");

    That's the only one I've ever used or gotten to work, but I'll experiment with the LoadVars object a little more. If you're still having problems, I recommend starting a new thread so we don't crowd this one with post.
    BC

  17. #37
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Please note that due to financial problems at my old Domain Registrar, my domain name of morgan-multinational.com has been poached. I am in the process of migrating all data to www.morganmultinational.com (Without the hyphen).

    This may take some time, but I will have this data working again soon.

    Best regards,

    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  18. #38
    Member
    Join Date
    Jun 2007
    Posts
    89
    Using the LoadVars object, I've been able to send data to a PHP file. I've simply included the variables within the URL. However, how do I retrieve data from a PHP file?

  19. #39
    Member
    Join Date
    Jun 2007
    Posts
    89
    Inspired by ForumNewbie and through experimentation, I've learned how to send and recieve data from PHP using 3DFA.

    3DFA -> PHP
    Code:
     //Variables
      loadvars_php = new LoadVars;
      url = "http://www...";
    
     //Setup loadvars_php
      //User-defined PHP variables
       loadvars_php.var1 = "any text";
       loadvars_php.var2 = "any text";
       loadvars_php.var3 = "any text";
       loadvars_php.result1 = "";
       loadvars_php.result2 = "";
    
      //Callback function
        loadvars_php.onLoad = function ()
        {
          //Variables
           buffer_result1 = "";
           buffer_result2 = "";
           ...
    
          //Retrieve PHP result
           buffer_result1 = this.result1;
           buffer_result2 = this.result2;
           ...
    
        }
    
     //Execute PHP
      loadvars_php.sendAndLoad(url, loadvars_php, "POST");
    PHP -> 3DFA
    Code:
    <?php
     //Retrieve 3DFA variables
      $buffer_var1 = $_POST['var1'];
      $buffer_var2 = $_POST['var2'];
      $buffer_var3 = $_POST['var3'];
    
     //Return result
      echo("&result1=any text&result2=any text...");
    
    ?>
    Last edited by man_id_unknown; 07-29-2007 at 07:24 PM.

  20. #40
    Member
    Join Date
    Jun 2007
    Posts
    89
    Keep in mind, (in my limited experience) I have learned that 3DFA requires PHP to precede its returned variables with an "&". As shown in the above example. However, KoolMoves, (and perhaps other Flash IDEs) requires PHP to not precede its returned variables with an "&".

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center