ironThink
11-29-2010, 04:15 PM
I have the PHP script below. When the Flash file calls this script it's suppose to build data from the database into an xml format and sent it back to the Flash file but I'm getting nothing:
?php
include_once('config/application.php');
$table = " `word_list` wl LEFT JOIN `region` r ON wl.`region_id`=r.`region_id` ";
$where = " ORDER BY r.`region_name` ASC";
$results = $database_obj->select_records($table, $where);
$xml_file = DOC_ROOT."cloudresults.xml";
if(file_exists($xml_file)) {
$fh = fopen($xml_file, 'w');
$header = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n\r<cloudList>\n\r";
fwrite($fh, $header);
if (count($results)!=0 && $results!="") {
foreach ($results as $result) {
$table = 'word_list';
$filter = ' SUM(popularity) as val ';
$where = ' WHERE region_id='.$result['region_id'].' GROUP BY region_id ';
$popula = $database_obj->select_filtered_record($table, $filter, $where);
$word_val = ($result['popularity']/$popula['val'])*100;
$word_val = number_format($word_val, 0);
$content = '<cloud cloudArea="'.strtoupper(stripcslashes($result['region_name'])).'" cloudWord="'.stripcslashes($result['word_description']).'" wordValue="'.intval($word_val).'"></cloud>';
fwrite($fh, $content);
}
}
$footer = "</cloudList>";
fwrite($fh, $footer);
fclose($fh);
}
?>
This is my Flash code:
var requestQ:LoadVars = new LoadVars();
url = ("getCloudData.php?rnum="+random(10000));
requestQ.load(url);
requestQ.onLoad = function(success) {
if (success){
trace(this)
}
};
Any help will be much appreciated. I think it might be something in the PHP code but I am befuddled
Thanks
?php
include_once('config/application.php');
$table = " `word_list` wl LEFT JOIN `region` r ON wl.`region_id`=r.`region_id` ";
$where = " ORDER BY r.`region_name` ASC";
$results = $database_obj->select_records($table, $where);
$xml_file = DOC_ROOT."cloudresults.xml";
if(file_exists($xml_file)) {
$fh = fopen($xml_file, 'w');
$header = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n\r<cloudList>\n\r";
fwrite($fh, $header);
if (count($results)!=0 && $results!="") {
foreach ($results as $result) {
$table = 'word_list';
$filter = ' SUM(popularity) as val ';
$where = ' WHERE region_id='.$result['region_id'].' GROUP BY region_id ';
$popula = $database_obj->select_filtered_record($table, $filter, $where);
$word_val = ($result['popularity']/$popula['val'])*100;
$word_val = number_format($word_val, 0);
$content = '<cloud cloudArea="'.strtoupper(stripcslashes($result['region_name'])).'" cloudWord="'.stripcslashes($result['word_description']).'" wordValue="'.intval($word_val).'"></cloud>';
fwrite($fh, $content);
}
}
$footer = "</cloudList>";
fwrite($fh, $footer);
fclose($fh);
}
?>
This is my Flash code:
var requestQ:LoadVars = new LoadVars();
url = ("getCloudData.php?rnum="+random(10000));
requestQ.load(url);
requestQ.onLoad = function(success) {
if (success){
trace(this)
}
};
Any help will be much appreciated. I think it might be something in the PHP code but I am befuddled
Thanks