Current location: Hot Scripts Forums » Programming Languages » PHP » Anyone know how to incorporate PHP and MySQL in Flash?


Anyone know how to incorporate PHP and MySQL in Flash?

Reply
  #1 (permalink)  
Old 05-11-06, 07:18 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Anyone know how to incorporate PHP and MySQL in Flash?

I've been reading this book--PHP 5 for Flash but I don't really like the way the author writes and explains things. Also...there are a lot of things that he doesn't explain along the way and creates these flash movies that are way more complex than I need.

I am only trying to load a few fields from the database (id, date, city and state) and display them in a dynamic text field in a list.

Thanks for you help,

Sonny
Reply With Quote
  #2 (permalink)  
Old 05-11-06, 08:17 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
can you post some of your php code?
how are you doing it? by writing an txt file? by echoing data through php? by setting up a socket?

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 05-12-06, 10:12 AM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
I want to echo through PHP. It is for my band's site. I designed everything in Flash and now I've been learning PHP and MySQL and want to be able to load all my tour dates in my flash movie.

Like I said before...I only need to load the fields id, date, city and state from the database.

Here's what I built to display it in HTML the way I want it:

PHP Code:

<?php

include ('./includes/config.inc.php');

require_once (
'./Connections/dbc.php'); // Connect to the db.

$today date('Ymd');
    
// Make the query.
$query "SELECT id, city, state, venue, time, DATE_FORMAT(date, '%m/%d/%y') AS date FROM tour WHERE date >= $today ORDER BY DATE_FORMAT(date, '%Y %m %d') ASC";        
$result = @mysql_query ($query); // Run the query.
$num mysql_num_rows($result);

if (
$num 0) { // If it ran OK, display the records.
    
echo '
    <table>
            <tr>
                <td align="left" width="100"><span class="bold">Date</span></td>
                <td align="left" width="160"><span class="bold">City/State</span></td>
                <td align="left" width="60"><span class="reg">&nbsp;</span></a></td>
            </tr>'
;    

    
// Fetch and print all the records.
    
while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
        echo 
'
            <tr>
                <td align="left" width="100"><span class="reg"> ' 
$row['date'] . '</span></td>
                <td align="left" width="160"><span class="reg"> ' 
$row['city'] . ',  ' $row['state'] .'</span></td>
                <td align="left" width="60"><span class="reg"><a href="details.php?id=' 
$row['id'] . '">details</span></a></td>
            </tr>'
;        
            
    }
echo 
'</table>';
    
    
mysql_free_result ($result); // Free up the resources.    

} else { // If it did not run OK.
    
echo '<p><span class="reg">There are currently no planned tour dates.</span></p>';
}

mysql_close(); // Close the database connection.

?>
I need to figure out 2 things:

1. How to change this script to output the data in flash correctly.
2. How to write the correct actionscript.

Any help would be awesome!

Sonny
Reply With Quote
  #4 (permalink)  
Old 05-12-06, 01:25 PM
Alli Alli is offline
Newbie Coder
 
Join Date: May 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
I just read the title:

if php want to communicate to flash best and easiest way is flashvars like this:

<param name="flashvars" value="var1=1&var2=2"> //IE
<embed flashvars="var1=1&var2=2"> //FF

and if flash want to communicate to php and get smt from it you must use LoadVars:

var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
rate = result_lv.new_rate; // data from php page
} else {
fscommand('alert', 'Flash couldn\'t connect to server.');
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.user_rate = user_rate; // data that must be send to php
send_lv.sendAndLoad("/game/rate.php?", result_lv, "POST");



I have used both in my site, but it's in persian.
Reply With Quote
  #5 (permalink)  
Old 12-25-07, 10:24 PM
sondogg's Avatar
sondogg sondogg is offline
Newbie Coder
 
Join Date: Feb 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes

I'm still needing some help with this. I'm struggling with understanding the actionscript that I would need to write in order to parse in the data from PHP.

I know that alot of folks just use XML to parse data into Flash. Can I edit my PHP script to output XML and do it that way?

How would my actionscript look? Please remember that there will be many results.

Thanks to all,

Sonny
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Php Mysql Bug??? tranquilraven PHP 4 03-01-06 03:06 AM
Need help with some php mysql TheTinkeringToad PHP 9 02-01-06 10:56 AM
flash mx to PHP to flash mx olm75 PHP 1 12-09-04 03:44 AM
WORKSHOP {Flash <-> PHP <-> MYSQL} zarko PHP 0 11-17-03 07:48 AM


All times are GMT -5. The time now is 07:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.