Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flash + PHP + MYSQL + Newbie = Hell

Status
Not open for further replies.

rubbersoul

IS-IT--Management
Mar 20, 2003
88
CA
OK....here's what I'm trying to do. I want to basically click a button and it populates on dynamic text field showing all the fiels in my one table called players (it's for a hockey league). So I have a database called 'stats' a table in there called 'players' and a bunch of fields (i.e. name, goals etc)...I wrote a .php page with the following code
PHP Code:
<?php

//Set up constants
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_USER', 'myName');
define ('MYSQL_PASS', 'myPassword');
define ('MYSQL_DB', 'stats');
//If we fail to connect
if (! mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) )
{
die('Failed to connect to host "' . MYSQL_HOST . '".');
}
else
{
echo 'Connected to mysql server ' . MYSQL_HOST . ' as user ' . MYSQL_USER . ' ';
}
//Tell mysql which database to use
mysql_select_db(MYSQL_DB);
echo 'Database ' . MYSQL_DB . ' selected for use.';

//Select entire table
$result = mysql_query('SELECT * FROM players');

echo $result;

?>

** As a side note when I view this page in a browser I get 'Connected to mysql server localhost as user myName
Database stats selected for use.'' So that part looks cool.....

Now for flash....here's where I get stuck....I have a new flash file open with 2 layers. On the first layer I have my dnamic text box and on the second an actions layer. I give the dynamic text box a variable and instance name of 'content' and on the actions layer I assign the following:
PHP Code:
loadVariables(" "this", "GET");


I test in flash and nothing.....I know I'm missing stuff....can any1 help? What I really need is for someone to show me the proper code. What do I have to name the dynamic text box instance and/or variable?
 
HAve you tried calling the PHP script in a browser rather than from Flash - you'll probably find that the $result variable isn't returning what you think it should: you need to parse $result to get all the information out using a structure like:

Code:
while($row=mysql_fetch_row($result)){
//format data here
}

...then you have to get that data into name/value pairs for Flash to be able to read it:

&var1=some data&var2=some data etc
 
When I run my PHP file in a browser I get...
Connected to mysql server localhost as user root
Database stats selected for use.

So I'm assuming I'm half way there!

 
So you're connected but you aren't getting the echo of the data returned from the SQL query - it's a data object that you have to 'unwrap' via the type of code I posted above. Without opening up the data contained in $result and formatting it correctly you won't be able to read it into Flash.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top