Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 09:21
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  Populate Combo Box AS3 & PHP & MySQL
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: Populate Combo Box AS3 & PHP & MySQL  (Read 2027 times)
JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« on: 02/03/10, 10:49 »

Hey guys,

I went through a posting of populating the comboBox with data from MySQL with PHP.

Here is the code:
import fl.controls.ComboBox;
import fl.data.DataProvider;

var 
myData:URLRequest = new URLRequest("http://localhost/MyChiParty/SITE/venueSelect.php");
myData.method URLRequestMethod.POST;

var 
loader:URLLoader = new URLLoader();
loader.dataFormat URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETEvenuesOnLoad);
loader.load(myData);

function 
venuesOnLoad(evt:Event) {
	
var 
venues:Array = new Array();
	
for (var 
i:uint=0evt.target.data.canti++) {
	
	
venues.push({label:evt.target.data["venue"+i], data:evt.target.data["venue"+i]});
	
}
	
venueCombo.dataProvider = new DataProvider(venues);
	
venueCombo.dropdownWidth 210;
	
venueCombo.prompt "Select a Venue";
}

stop();

PHP Code:



<?PHP

require("_dbinfo-LOCAL.php");

$link mysql_connect("localhost",$username,$password);
mysql_select_db($database);

$result mysql_query("SELECT name FROM venues");
$cant 0;
while(
$row=mysql_fetch_array($result)){
	
echo 
"venue$cant=$row[name]&";
	
$cant++;
}

mysql_close($link);
?>



I keep getting the error:

Error #1069: Property cant not found on String and there is no default value.

any help would be great Thanks!
« Last Edit: 02/03/10, 13:00 by Jorge Solis » Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #1 on: 02/03/10, 13:03 »

First: comment all the lines inside venuesOnLoad function, then add one by one until you get the error, I guess probably will be in the venues.push line because you don't get data in the correct format

Jorge
Logged

JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #2 on: 02/03/10, 13:31 »

Hey Jorge Thanks,

But I am still getting the error and I have no idea of going about fixing this.

I tried the commenting out the lines and I know what line it is...

for (var i:uint=0; i<evt.target.data.cant; i++) {

but no idea what to do next

Thankx in advance
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #3 on: 02/03/10, 13:37 »

That means cant doesn't come correctly in PHP, open directly the PHP file and check that the output looks correctly

Jorge
Logged

JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #4 on: 02/03/10, 13:59 »

Yea it comes up fine directly:

"venue78=The Kerryman&
venue79=Seven Ten Lounge&
venue80=Southport Lanes&
venue81=Zella&
venue82=State&
venue83=The Pony&
venue84=Chaise Lounge&
venue85=test&
cant=86 "

So I don't know where I am going wrong in AS#
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #5 on: 02/03/10, 14:38 »

The're is an extra space after 86, to be sure, put all the output in a single line and add a separator (&) after the last piece of data

Jorge
Logged

JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #6 on: 02/03/10, 14:54 »

This is the last line:

Lounge&cant=80venue80=Southport Lanes&cant=81venue81=Zella&cant=82venue82=State&cant=83venue83=The Pony&cant=84venue84=Chaise Lounge&cant=85venue85=test&
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #7 on: 02/03/10, 18:50 »

It's wrong, you repeat cant for every row and should be only at the end:

&cant=80venue80

Also there's no & between cant and the next variable. In the PHP you have posted the cant variable doesn't exist, add at the end like this:

echo "cant=$cant&";
mysql_close($link);

Jorge




Logged

JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #8 on: 02/03/10, 22:31 »

I'm sorry to keep bothering you,

But is there any way I could see an example of the as3 and php because now I am getting the

" Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs."

Thanks in Advance
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #9 on: 02/04/10, 07:25 »

All this errors are because can't parse the PHP output, check again the last lines of your output, looks ok?

Jorge
Logged

JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #10 on: 02/04/10, 11:34 »

Yea I really do not know what to do wtih this.  I cannot get this to work to save my life.  If you could show me code to get this thing to work I would REALLY appreciate it because today is the last day I am going to try and get this thing going.

Thanks in Advance
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #11 on: 02/04/10, 12:04 »

Just a thought:

are you using a free hosting provider, which inserts advertising into the results?

How does the php output look like?
Logged

happy flashing
Cool
Ronald
JKofSpades
Server what's that
*
Posts: 10


View Profile Email
« Reply #12 on: 02/04/10, 12:34 »

Here is the php and the last line of the output:

<?PHP
require("dbinfo-LOCAL.php");

$link = mysql_connect("localhost",$username,$password);
mysql_select_db($database);
$table = "venues";

$result = mysql_query("SELECT name, address FROM $table");
$cant = 0;
while($row=mysql_fetch_array($result)){
   echo "name$cant=$row[name]";
   $cant++;
}
echo "cant=$cant";

mysql_close($link);
?>


The last couple of lines from the output are:


name0=Rockit Bar & Grillname1=Rockit Bar & Grill - Wrigleyvillename2=The Underground Chicagoname3=WestEnd Tapname4=Joe's on Weed Streetname5=Madpoison Ultra Loungename6=NV Penthouse Loungename7=Angels & Mariachisname8=Level Nightclubname9=Mahoney's Pub & Grillename10=Crescendoname11=Aberdeenname12=Manorname13=Cagney's Restaurant & Sports Loungename14=Stay Loungename15=Casey Moran'sname16=RiNo Loungename17=Red Ivyname18=Lucky Ladyname19=Risque Caféname20=The Cedar Hotelname21=Purple Hazename22=Debonair Social Clubname23=Rebel Bar & Grillename24=Griffin Loungename25=Waterhouse Tavern & Grillname26=Amp Rock Loungename27=BlueLight Loungename28=Pitch Forkname29=Cactus Bar & Grillname30=Franklin Tapname31=The Hangge Uppename32=Crobar Nightclubname33=Flounders Bar & Grillname34=Excaliburname35=Visions Night Clubname36=Grand Centralname37=Lumenname38=Bar Celonaname39=SoPo Loungename40=John Barley Corn Lincoln Parkname41=John Barley Corn Wrigleyvillename42=Landmark Grillname43=Mystic Celtname44=Tracename45=Moe's Cantinaname46=Elm Street Liquorname47=Goodbarname48=The Original Mother'sname49=Mother's Tooname50=EnClavename51=The Stretchname52=Spoonname53=MaxBarname54=The Lodgename55=Bootleggersname56=Moxiename57=SkyBarname58=Pippins Tavernname59=Evil Olivename60=Slow Downname61=Junior's Sports Loungename62=She-Nannigans House of Beername63=Salud Tequila Loungename64=McFadden's Saloon & Restaurantname65=Le Passagename66=Streeters Tavernname67=The Drawing Roomname68=JBarname69=Cans Bar & Canteenname70=Halligan's Barname71=Cortland's Garagename72=Angels & Kingsname73=Old Town Socialname74=The Red Canaryname75=Bull & Bearname76=Stone Lotusname77=Touch iBarname78=The Kerrymanname79=Seven Ten Loungename80=Southport Lanesname81=Zellaname82=Statename83=The Ponyname84=Chaise Loungename85=testcant=86



I took the ampersand out because I kept getting the error about the URL encoding variables.  Then I changed in AS3 from URLLoader.VARIABLES to TEXT and

then I kept getting the error "property cant not found on string and there is no default value.


So I REALLY dont know where to go now.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #13 on: 02/04/10, 12:48 »

Ok, modify like this:

while($row=mysql_fetch_array($result)){
   echo 
"name$cant=$row[name]&";
   
$cant++;
}
echo 
"cant=$cant&";

That's it, you are not using &

Jorge
Logged

Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #14 on: 02/04/10, 13:22 »

how do the first lines look like?
Logged

happy flashing
Cool
Ronald
Pages: [1] 2 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything