polemios Posted October 3, 2007 Share Posted October 3, 2007 I know this has been asked before and I have read several threads elsewhere that sort of cover the topic, but nothing is helping me. Briefly, here's the issue: I have made a flash file that parses an XML file to get its content. I've tested it with a static XML and it works great. Let's call that XML "xml1". I have made a MYSQL db and the accompanying PHP files to dynamically add information to the database. This works great. I tried to use PHP to output an XML file to replace the static one, thus completing the circle and allowing the client to enter data into the db and see it in flash. Let's call this one "xml2". The flash file won't accept the data from "xml2". I assume it's in some sort of doctype issue. By the way, I thought it might be the fact that the extension of "xml2" is .php instead of .xml, but that doesn't matter. "xml1" was successfully tested with a .php extension. When I view "xml2" in a browser, it looks like it's being treated like html instead of XML, but when I view the source, it looks exactly like the code from "xml1". What is the difference? Here's the code for "xml2", the problematic one: <?php print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" . "\n<diary>"; require "./includes/db.php"; require "./includes/functions.php"; require "./includes/authentication.php"; //Connect to server if (!($connection = @ mysql_connect($hostName, $username, $password))) showerror(); if (!mysql_select_db($databaseName, $connection)) showerror(); //Run a query to pull in the names, to use in the following list $query="SELECT entry_id, entry_date, entry_month, entry_year, entry_day, entry_words, entry_img_url FROM diary_entries ORDER BY entry_year DESC, entry_month DESC, entry_date DESC"; if (!($result = @ mysql_query ($query, $connection))) showerror(); while ($row = @ mysql_fetch_row($result)) { print "\n<entry>" . "\n\t<date>{$row[1]}</date>". "\n\t<month>"; monthNumberToName($row[2]); print "</month>" . "\n\t<day>{$row[4]}</day>". "\n\t<words>"; formatXML($row[5]); print "</words>" . "\n\t<img>{$row[6]}</img>" . "\n</entry>"; } print "\n</diary>"; ?> Here's "xml1"; what "xml2" should replicate in a dynamic setting: <?xml version="1.0" encoding="iso-8859-1"?> <diary> <entry> <date>10</date> <month>September</month> <day>Saturday</day> <words>Blah Blah Blah</words> <img>./Images/Diary/whistle.jpg</img> </entry> </diary> Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 It may be that the script is not making it through the PHP parser. I'm not sure how it works when a flash application opens a file, but if the request isn't handled by Apache, the flash application will just get the raw PHP code and choke. I don't know Flash, but I imagine there's a way to invoke PHP, even if it has to be something as kludgy as executing a shell command. Quote Link to comment Share on other sites More sharing options...
haaglin Posted October 3, 2007 Share Posted October 3, 2007 add this at the top: header('Content-Type: text/xml'); It should be parsed as xml. Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 But only if it's being delivered to the Flash application by Apache. If the Flash application is simply grabbing the file off the hard drive, the script never goes through the PHP parser. Instead of trying to process the file, simply output it as text within your Flash application. This will tell you whether the PHP is actually being interpreted or not. Quote Link to comment Share on other sites More sharing options...
haaglin Posted October 3, 2007 Share Posted October 3, 2007 But only if it's being delivered to the Flash application by Apache. If the Flash application is simply grabbing the file off the hard drive, the script never goes through the PHP parser. Instead of trying to process the file, simply output it as text within your Flash application. This will tell you whether the PHP is actually being interpreted or not. Flash is not a server based language.. and therefore the only way to fetch a file would be a request to the server for the file.. in the same way you request the file when you use you browser. it will be delievered by apache when you request the file, because flash has no access to get the file any other way.. Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Yes, you are right. I guess it would have to go through the web server. I would still do what I suggested. Output "xml2" as text within your Flash application to see exactly what is being delivered to your application by the web server. Quote Link to comment Share on other sites More sharing options...
polemios Posted October 3, 2007 Author Share Posted October 3, 2007 Well, it seems that the content type addition helped the browser display it as an XML. It appears to be perfect. But for some reason, Flash still isn't getting the info from it. It reads in a browser and in it's source exactly like "xml1". I know this isn't an actionscript forum, so i won't bore people. I wonder why it still isn't loading it. I can only assume it's in the PHP to XML process since the identical "xml1" loads fine. Wierd. Quote Link to comment Share on other sites More sharing options...
haaglin Posted October 3, 2007 Share Posted October 3, 2007 What code are you using to get the file in the flash file? Quote Link to comment Share on other sites More sharing options...
polemios Posted October 3, 2007 Author Share Posted October 3, 2007 I'm using Flash's built in XML object. I then use actionscript to parse the XML into usable variables for my application. It really baffles me. Right now, thanks to your help, the two XML files behave identically. Except that one gets parsed into Flash and the other doesn't. I think I'll move this discussion to actionscript.org. Maybe. Quote Link to comment Share on other sites More sharing options...
polemios Posted October 3, 2007 Author Share Posted October 3, 2007 Hahaha. I wasn't testing the Flash movie inside my PHP server! What a foolish thing! I don't believe it! Thanks for all your help -L Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.