PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
php and flash as3 mysql database connection variables
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: php and flash as3 mysql database connection variables

  1. #1
    Flash Genie letschillout's Avatar
    Join Date
    Feb 2007
    Location
    31.52949, 74.347272
    Posts
    146

    php and flash as3 mysql database connection variables

    am connecting flash with mysql database
    but not able to get proper variable value.

    i want output "connected"
    by defining
    var s = evt.target.data.server;

    also can someone explain me more about these two i.e.
    //loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    //loader.dataFormat = URLLoaderDataFormat.TEXT;


    am getting sometime value i.e.

    connected <br> etc .........why am getting html code in it? any idea

    Thanks
    ---------------------------
    php connection i.e.
    PHP Code:
    <?php

    /** MySQL database username */
    define('DB_NAME''nippers');
    define('DB_USER''root');
    define('DB_PASSWORD''admin');
    define('DB_HOST''localhost');

    $output .="<loginserver>";
    $connect mysql_connect(DB_HOSTDB_USERDB_PASSWORD) or die(mysql_error());
    if (!
    $connect)
      {
      
    $output .= "Not Connected";
      
    //die('Could not connect: ' . mysql_error());
      
    }
    else
    {
        
    $output .= "Connected";
        
    //echo "Connected to MySQL<br />";
    }

    // some code
    //mysql_close($con);

      
    $returnVars .="server = connected ";
     
      
    $output .= "</loginserver>";  
    //  print ($output);
      
    print ($returnVars);



    //Selecting database
    $select_db mysql_select_db(DB_NAME$connect);
    if(!
    $select_db){
    die(
    mysql_error());
    }
    ?>


    AS3 code i.e.

    Actionscript Code:
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLRequestMethod;
    import flash.text.TextField;
    import flash.events.IOErrorEvent;
    import flash.net.URLLoaderDataFormat;

       



    function Main()  {
       
    //var myXML:XML = new XML();
    var myXML_URL:String;

    var url:String = "http://localhost/score/add/database.php";
    var _var:URLVariables = new URLVariables();

    var request_url:URLRequest = new URLRequest(url);
    var loader:URLLoader = new URLLoader(request_url);
    //loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    //loader.dataFormat = URLLoaderDataFormat.TEXT;
    //request_url.data = myXML.toXMLString();
    request_url.method = URLRequestMethod.GET;
    //request_url.data = _var;
    //request_url.contentType = "text/xml";


    loader.addEventListener(Event.COMPLETE, completeHandler);
    loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, secerror);

    _var.server = server.text;
    loader.load(request_url);

    function completeHandler(evt:Event) {
       
        //var data:URLVariables = new URLVariables( loader.data );
        //trace( data.filesize );

      //var _loader:URLLoader = URLLoader(evt.target);
      //trace ("value: "+_loader.data.output);
     
     
      //myXML = XML(loader.data);
      //trace ("value: "+ myXML);
      var s = evt.target.data.server;
      trace ("value: "+ s);
      nowstatus.text = s;
     
    }

    function onIOError(event:IOErrorEvent):void {
    trace("Error loading URL.");
    }

    function secerror(event:SecurityError) {
        nowstatus.text = event.message;
    }
    try {
        loader.load(request_url);
    }
    catch (error:IOError) {
        nowstatus.text = "error: " + error.message;
    }
    catch (error:Error) {
        nowstatus.text = "error: " + error.message;
    }

    }

    Main();
    Last edited by letschillout; 05-23-2011 at 02:50 AM.
    Charag - 3D, Flash Games, Animations,
    Website Development & More...


  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    try this:
    $returnVars .="server=".$output;
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

Tags for this Thread

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