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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql -> php -> flash

Status
Not open for further replies.

patfee

Programmer
Dec 14, 2004
78
NL
Hi,

I'm trying to use a php script to fetch data from mysql and present is as a xml file.
The xml file is to be read by flash.

i'm using php script as down below.
When i access this script through my browser, the output is perfectly alright.

Trying to access it in Flash... nothing happens.

On the flash stage i'm using an XML connector, a Dataset and a datagrid.
the action script included is xml_conn.trigger();
this works fine with a plain XML file (xml_conn points to mydata.xml) , but i can not get it working for a php generated xml file (xml_conn point to the php file).

i suspect it has something to do with xml_conn.trigger()? or the XML data generated with the php dom function is incompatible with the format required by flash?

Any sugestions please?

Thanks
PAtrick

$table_id = 'some_table';
$query = "SELECT * FROM $table_id";
$dbresult = mysql_query($query, $dbconnect);
// create a new XML document
$doc = new DomDocument('1.0');
// create root node
$root = $doc->createElement('root');
$root = $doc->appendChild($root);
// process one row at a time
while($row = mysql_fetch_assoc($dbresult)) {
// add node for each row
$occ = $doc->createElement($table_id);
$occ = $root->appendChild($occ);
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
// add a child node for each field
foreach ($row as $fieldname => $fieldvalue) {
$value = $doc->createTextNode($fieldvalue);
$value = $child->appendChild($value);
} // foreach
} // while
// get completed xml document
$xml_string = $doc->saveXML();
echo $xml_string;
?>
 
I do this type of thing in ASP.NET all the time. What I do is open the web page (PHP) in your case, then copy and paste that into a static xml file. Use the static file to import the schema to your XMLConnector in Flash.

Also make sure that you are using a fully qualified URL in the connector "path" field so that the server is doing the work you think it's doing.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top