Jump to content

jammydevil

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by jammydevil

  1. Never mind, I've fixed the problem. For anybody wanting to know, I hadn't set the headers correctly. I needed to add [code]header("Content-Type: text/xml");[/code] after the DomDocument is created. This allows Firefox to read the file as an XML file where as Internet Explorer isn't as picky.
  2. Hello, I have a news PHP script using data from a MySQL database. I've used the below PHP script to extract the most recent three entries and create an XML file. This is then used by JavaScript to display the data in a rotating news display, similar to that found at [url=http://www.mlsnet.com]http://www.mlsnet.com[/url]. [code]include('news/flash/admin/functions.php'); connect('username','password','hurri_news','localhost'); $query = "SELECT newsid, image, title, home, DATE_FORMAT(date, '%M %d, %Y') as date FROM news_posts ORDER BY newsid DESC LIMIT 3"; $result = mysql_query($query); // 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_array($result)) { // add node for each row $occ = $doc->createElement("news"); $occ = $root->appendChild($occ);   // add a child node for each field $child = $doc->createAttribute("id"); $child = $occ->appendChild($child); $value = $doc->createTextNode(stripslashes2($row['newsid'])); $value = $child->appendChild($value); $child = $doc->createAttribute("img"); $child = $occ->appendChild($child); $value = $doc->createTextNode(stripslashes2($row['image'])); $value = $child->appendChild($value); $child = $doc->createAttribute("title"); $child = $occ->appendChild($child); $value = $doc->createTextNode(stripslashes2($row['title'])); $value = $child->appendChild($value); $child = $doc->createAttribute("body"); $child = $occ->appendChild($child); $value = $doc->createTextNode(stripslashes2($row['home'])); $value = $child->appendChild($value); } // while // get completed xml document $xml_string = $doc->saveXML(); echo $xml_string;[/code] I have managed to create the XML file and the script works perfectly in Internet Explorer 7 but does not work at all in Firefox. When I view the source in Firefox the data is displayed properly but JavaScript can't seem to use the data correctly. The JavaScript works fine when using a static XML file in both browsers but that would defeat the purpose of using the database. Can anybody advise me the best way to approach this problem or why Firefox would have trouble displaying this data? If this is the wrong forum I apologise. Thanks, Jay
  3. [a href=\"http://aleembawany.com/weblog/webdev/000051_ajax_instant_tutorial.html\" target=\"_blank\"]AJAX Tutorial[/a] I found this website pretty helpful. Jay
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.