CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Flash & ActionScript (http://www.codingforums.com/forumdisplay.php?f=52)
-   -   Loading MySQL data from a PHP file into Flash (http://www.codingforums.com/showthread.php?t=229199)

GJ384 06-12-2011 02:45 PM

Loading MySQL data from a PHP file into Flash
 
Hi there,

I have a PHP file which loads data from a MySQL database, displaying the contents of one field from one row on screen. Once this has happened, a Flash movie then loads the output of the PHP file and displays it in a dynamic text box. At least, that's what it did until I converted the manually-created database I was using into a Wordpress-managed one, in order to set up a custom CMS for my client...

The PHP file is correctly (I believe) loading the data and showing it on screen, but the Flash movie is no longer displaying that data in the text box. Instead, the contents of the text box appear to be blank.

First, here's my PHP (loader.php):

PHP Code:

<?php
$page_id
=$_GET['page_id'];

$db mysql_connect('localhost''***''***');
if (!
$db) {
    die(
'Not connected: ' mysql_error());
}

$db_selected mysql_select_db("thetrain_wordpress",$db);
if (!
$db_selected) {
    die(
'Error: ' mysql_error());
}

$query "SELECT * from wp_posts WHERE ID = '$page_id'";
$request mysql_query($query);

for(
$k 0$k mysql_num_rows($request); $k++){
    
$row mysql_fetch_row($request);
    print 
/* "&row_".$k."=". */ $row[4];    // echo string to url
}
?>

As I said, this part appears to work correctly - when the page is accessed directly in a browser (by pointing the browser to "loader.php?page_id=2") the browser displays the string "text" - which is exactly what is stored in the database cell I'm trying to access. So I don't think this is where the problem lies - but I thought I'd add it in just to demonstrate what I'm doing.

Next, here's the HTML on the page holding the Flash movie:

Code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>***</title>
</head>
<body bgcolor="#00ccff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="TrainShedMkIV" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="TrainShedMkIV.swf" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#00ccff" /><embed src="TrainShedMkIV.swf" loop="false" menu="false" quality="best" bgcolor="#00ccff" width="100%" height="100%" name="TrainShedMkIV" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

And finally, the ActionScript:

Code:

AmenitiesData = new LoadVars();
AmenitiesData.onLoad = function(){
        AmenitiesText_txt.html = true;
        AmenitiesText_txt.htmlText = "";
        loadedText = "";
        for(var i in this) {
                loadedText += i + " = "+this[i];
        }
        loadedText = loadedText.slice(0,-24);
        AmenitiesText_txt.htmlText = loadedText;
}
onLoad = AmenitiesData.load('dynamic/loader.php?page_id=2');

NB: AmenitiesText_txt is the instance name of the text box into which I'm trying to load the output of the PHP file.

Like I said, the problem is that the text box in the Flash movie is just coming up blank.

Admittedly, it's all pretty messy, and there's probably an easier way to make all of this work. But does anyone have any ideas as to what I might want to check? I'm highly suspicious that it's going to be something irritatingly simple, and I'll feel silly for not thinking of it myself...

I'd also be open to any suggestions of completely different (and hopefully simpler) ways to achieve the same end result!

Thanks in advance...

Gareth

DocPranav 06-16-2011 11:08 AM

I do not see any issues with the code to be honest. I think it is all about the platform where you are running the code. I tried and copy it on my laptop and seems everything works fine. Do you have a virtual machine that you can use to try your codes?


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.