Flash CS3 <-->PHP<-->MySQL (Almost there!)

Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default Flash CS3 <-->PHP<-->MySQL (Almost there!)

    I am working on the Flash CS3/PHP/MySQL integration and I think I am almost
    there.

    Below is the script in my .fla. This script is calling the register.php
    script to pass the variables reg_user (String), reg_pass(String), reg_mail
    (String) and sql_type (Integer).

    In register.php, I am displaying the results of the DB action and it's showing
    &n=0&

    The php script is working fine. I have tested by direct placement and value
    assignment ( $reg_user="Tsitsi",
    $reg_pass="password",$reg_mail="tsitsi@els.co.za" and $sql_type=1) in the php
    script.

    So what is wrong with the script below? It seems to be failing to 'transmit'
    the values over to the php script?

    import flash.display.Sprite;
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    import flash.net.URLVariables;
    var u:String="Tsitsi"
    var p:String="password"
    var e:String="tsitsi@els.co.zw"
    var t:int=1
    var variables:URLVariables = new URLVariables();
    variables.reg_user=u
    variables.reg_pass=p
    variables.reg_mail=e
    variables.sql_type=t
    trace(variables)
    var url:String = "http://localhost:81/flash/register.php";
    var request:URLRequest = new URLRequest(url);
    request.method = URLRequestMethod.POST;
    request.data = variables;
    navigateToURL(request);

    Mwalimo Guest

  2. Similar Questions and Discussions

    1. flash/php/mysql
      Hi, so I've created an html/php questionnaire that sends user entered information to a mysql database. After people submit their information I'd...
    2. Export Querries from Flash 8 to MySQL and Import Datafrom MySQL
      Hi friends, I am making a web site for a customer and i need to import data from MySQL Database but i don't know how to do it. I would appreciate...
    3. PHP / MySQL / Flash 8
      I've created a simple MySQL Database, query via PHP and then load in the vars via LoadVars ( in Flash ). Everything seems ok. But when I see the...
    4. ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
      When i try to start my mysql server, i get this error ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'...
    5. flash + php + mysql
      i have a blog which currently uses php + mysql only and i wanted to integrate the data into flash,this is what i did in the php version of my blog(...
  3. #2

    Default Re: Flash CS3 <-->PHP<-->MySQL (Almost there!)

    Hello there,

    I think the problem is in how you're capturing the variables in your PHP
    script. I created an example using your Actionscript code and it works fine.
    Instead of hard coding the values for the variables in the script, I created a
    registration form and got the values from input textfields. Once you hit the
    SUBMIT button a window opens in the browser and a PHP file catches all the
    submitted data and outputs the results.
    Below is the code I used in both Flash and PHP files. You can view the
    example here and download the files here.

    Hope that helps!



    [ACTIONSCRIPT]

    import flash.net.*;

    submit_btn.addEventListener(MouseEvent.CLICK, submitForm);
    reset_btn.addEventListener(MouseEvent.CLICK, resetForm);

    function submitForm(event:MouseEvent):void
    {
    var u:String = user_txt.text;
    var p:String = pass_txt.text;
    var e:String = email_txt.text;
    var t:int = 1;

    var variables:URLVariables = new URLVariables();
    variables.reg_user = u;
    variables.reg_pass = p;
    variables.reg_mail = e;
    variables.sql_type = t;

    var url:String = "http://localhost/FLASH/register.php";
    var request:URLRequest = new URLRequest(url);
    request.method = URLRequestMethod.POST;
    request.data = variables;
    navigateToURL(request);
    }

    function resetForm(event:MouseEvent):void
    {
    user_txt.text = "";
    pass_txt.text = "";
    email_txt.text = "";
    }


    [PHP]

    <?php

    echo "This is the array result that is returned from the Flash form<br><br>";

    foreach($_POST as $key=>$val)
    {
    echo "$key = $val <br>";
    }

    echo
    "<br>----------------------------------------------------------------------<br><
    br>";

    echo "Registration results: ";

    if(isset($_POST['reg_pass']))
    {
    $pass = $_POST['reg_pass'];
    $user = $_POST['reg_user'];
    $email = $_POST['reg_mail'];

    if($pass == "" || $user == "" || $email == "")
    {
    echo "Please fill in all fields! <br>";
    } else {

    // Insert details into database

    echo "Thank you <strong>$user</strong>, you have been registered!
    <br>";
    }
    }

    ?>

    Noelbaland Guest

  4. #3

    Default Re: Flash CS3 <-->PHP<-->MySQL (Almost there!)

    Thank you Noelaland
    Mwalimo Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139