A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Tab'd Flash with PHP/MySQL and sendAndLoad( )

  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    1

    Tab'd Flash with PHP/MySQL and sendAndLoad( )

    Hello All,

    I am pretty new at this, I am creating a tabbed form. It has 8 tabs and 10 scenes.

    In my "Home" tab, I load up some data from a MySQL database with the below action script:

    Code:
    stop();
    Selection.setFocus( "q" );
    
    loadVariables( "http://www.mysite.com/fmf/fmfhome.php", this, "GET" );
    On the "Home" tab, there is a button which loads up another Scene. In that Scene called "ListFiles" it has a dataGrid and a comboBox. Both data for each of the dataGrid and comboBox is populated via a PHP->MySQL script.

    The code for that looks like:

    Code:
    var listItemCatArray:Array	= []; 
    
    listCatCB.dataProvider		= listItemCatArray; 
    var catSender:LoadVars		= new LoadVars( ); 
    var catReceiver:LoadVars	= new LoadVars( ); 
    
    catReceiver.onLoad = function( ok )
    { 
    
    	listCatCB.removeAll( ); 
    	listItemCatArray.push( "All Categories" ); 
    
    	if ( ok ) { 
    		for ( var i =1; i <= catReceiver.catTotal; i++ ) { 
    			var _cname:String			= catReceiver[ "cat" + i ]; 
    			listItemCatArray.push( _cname ); 
    			delete( catReceiver[ "data" + i ] ); 
    
             }
    
             listCatCB.dataProvider = listItemCatArray; 
    
         } else { 
             listCatCB.removeAllColumns( ); 
             listCatCB.removeAll( ); 
             listItemCatArray.push( { status:"No data for this category!" } ); 
    
             listCatCB.dataProvider = gridArray; 
    
    	} 
    
    }
    
    catSender.sendAndLoad( "http://www.mysite.com/fmf/fmflistitems.php?q=1", catReceiver, "POST" );
    
    /* ------------------------------------------------------------------------- */
    
    var listItemGridArray:Array	= []; 
    
    listItemGridArray.push( { status:"Loading item list now..." } ); 
    
    listItemGrid.dataProvider		= listItemGridArray; 
    var uilSender:LoadVars			= new LoadVars( ); 
    var uilReceiver:LoadVars		= new LoadVars( ); 
    
    uilReceiver.onLoad = function( ok )
    { 
    
    	if ( ok ) { 
    		listItemGrid.removeAllColumns( ); 
    		listItemGrid.removeAll( ); 
    
    		for ( var i =1; i <= uilReceiver.uilTotal; i++ ) { 
    			uilReceiver[ "uilDataPacket" + i ]	= uilReceiver[ "uilData" + ( i ) ].split( "|" ); 
    
    			var _id:String			= uilReceiver[ "uilDataPacket" + i ][ 0 ]; 
    			var _submitter:String	= uilReceiver[ "uilDataPacket" + i ][ 1 ]; 
    			var _date:String		= uilReceiver[ "uilDataPacket" + i ][ 2 ];
    			var _description:String	= uilReceiver[ "uilDataPacket" + i ][ 3 ]; 
    			var _location:String	= uilReceiver[ "uilDataPacket" + i ][ 4 ]; 
    			var _type:String		= uilReceiver[ "uilDataPacket" + i ][ 5 ];
    			var _size:String		= uilReceiver[ "uilDataPacket" + i ][ 6 ];
    
    			listItemGridArray.push( { Description:_description, uploadDate:_date, Submitter:_submitter, Type:_type, Size:_size } ); 
    
    			delete( uilReceiver[ "uilData" + i ] ); 
    
             } 
    
             listItemGrid.dataProvider = listItemGridArray; 
    
         } else { 
             listItemGrid.removeAllColumns( ); 
             listItemGrid.removeAll( ); 
             listItemGridArray.push( { status:"No data for this category!" } ); 
    
             listItemGrid.dataProvider = gridArray; 
    
    	} 
    
    }
    
    uilSender.sendAndLoad( "http://www.mysite.com/fmf/fmflistitems.php?q=2", uilReceiver, "POST" );
    My issue is that, once I view the dataGrid & comboBox after clicking the button on the "Home" tab (obviously taken to the scene "ListFiles"), when I choose to go back to my "Home" tab scene, the loadVariables( ) loads the url with all the HTTP request variables and I get the following output:

    Code:
    Error opening URL "http://www.mysite.com/fmf/fmfhome.php?sumItems=653&sumSize=565%2E33+MBs&sumCats=17&largeCat=Funny+%28272+items%29&uploader=adsouza&uploadDate=02%2D03%2D2006+04%3A29%3A14+PM&tickerClass=%5Btype+Function%5D&listItemCatArray=All+Categories%2CBrianni%2CFlash%2CFriends%2CFunny%2CHalloween+2005%2CKayla%2CLy...
    I can't seem to figure, how come my loadVariables:
    Code:
    loadVariables( "http://www.mysite.com/fmf/fmfhome.php", this, "GET" );
    keeps getting morphed into:
    Code:
    loadVariables( "http://www.mysite.com/fmf/fmfhome.php?sumItems=653&sumSize=565%2E33+MBs&sumCats=17&largeCat=Funny+%28272+items%29&uploader=adsouza&uploadDate=02%2D03%2D2006+04%3A29%3A14+PM&tickerClass=%5Btype+Function%5D&listItemCatArray=All+Categories%2CBrianni%2CFlash%2CFriends%2CFunny%2CHalloween+2005%2CKayla%2CLy", this, "GET" );
    Any help would be appreciated!!!

    Thanks!!!!

    Anthony

  2. #2
    Flash Filosopher
    Join Date
    Apr 2006
    Location
    Washington
    Posts
    68
    Okay, after some researching, here is a hazarded guess as to what may be going on here.

    First off, "Error opening URL" can occur for a variety of reasons, one being transmitted variables being messed up somehow.

    Since you are using the HTTP GET method, which appends the variables to the end of the query string rather than POST on that query, it seems that it is not your loadVariables code itself that is getting morphed, rather it is actually that loadVariables does correctly requests the data, but then somewhere in the variable string that is being returned, an error occurs.

    I noticed that one of the params in the string looks like this:
    Code:
    &listItemCatArray=All+Categories%2CBrianni%2CFlash%  2CFriends%2CFunny%2CHalloween+2005%2CKayla%2CLy
    which is interesting - note the spaces in the url (assuming of course that this is the actual text you received and hasn't been broken somewhere else for a line break).

    Given that some browsers don't see URL's with spaces to be properly formatted, and will give you an error if you try to access such a URL, it's possible that the spaces in this data being returned may be throwing the error. Of course, this is just a guess, but would you be able to use the POST method instead of the GET method here? It may help. Otherwise, I'd check to see what or how that variable is being returned such that there is a space in the query response - it seems odd. If you're able to see that this is a problem and can check or fix this and the error still occurs, let me know.

    HTH

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