Click to See Complete Forum and Search --> : I really need some help here - PHP and FLASH


braddles69
06-30-2006, 08:18 AM
Hi,

I'm currently building a Flash website but I need it to be able retrieve text from a MySQL database - to make it easier to update.

I've had some help from a few online tutorials and have managed to get it kind of working. When I open the .swf locally (straight off my hard drive) it retrieves the text from the database with no problems - however it does display the following message onscreen quickly before the text is loaded: _level0.pass_var (where pass_var is the variable I am trying to pass from PHP to Flash aswell as the variable name of the dynamic text field the text should be loaded into)

However if I open the html file with the swf embedded in it, it only displays the _level0.pass_var message and doesn't load the text from the database. The same happens if I try to open the swf or html on my server.

Below is the PHP code I have written (content_handler.php):

<?php

$target_page = $_GET['page'];

$global_dbh = mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect to host.");
mysql_select_db($dbname, $global_dbh) or die("Could not find database.");

$query = "SELECT Content FROM $tablename WHERE Page = '$target_page' ORDER BY ID DESC LIMIT 1";
$result = mysql_query($query, $global_dbh);
$data = mysql_fetch_array($result);

$pass_data = $data['Content'];

echo "&pass_var=$pass_data";

mysql_free_result($result);
mysql_close($global_dbh);

?>


Below is the ActionScript code (from my Flash movie), on the same frame (but different layer) as the dynamic textfield - pass_var:

stop();
loadVariables("http://somedomain.com.au/flash_test/content_handler.php?page=about_us","","GET");


There is a very good chance that the code I've written is crap as I'm new to flash... I'd really appreciate some help with this... if anyone can. It's driving me crazy.

Thanks a lot,

Brad