spangle1187 Posted January 28, 2011 Share Posted January 28, 2011 Hi guys and girls, I am trying to create an XML document from an php document and a sql_query but I am getting this fatal error: Fatal error: Call to undefined method DOMComment::createElement() in /content_ro/webdev/htdocs/schools/hhs/psy_bookings/home.php on line 15 <?php include("php/dbconnect.php"); //connects to the database $table_id = 'booking'; $query = "SELECT * FROM $table_id WHERE (booking.bookingDate = curDate()) AND roomID = 1 ORDER BY startTime"; $room1 = mysql_query($query); //create a new DOM document $doc = new DOMComment('1.0'); //create root element $root = $doc->createElement('root'); $root = $doc->appendChild($root); //process one row at at time while($row = mysql_fetch_assoc($room1)){ //add node for each row $occ = $doc->createElement($table_id); $occ = $doc->appendChild($occ); //add achild for each field foreach ($row as $fieldname => $fieldvalue){ $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } } mysql_free_result($room1); $xml_string = $doc->saveXML(); echo $xml_string; ?> I am following a tutorial on http://www.tonymarston.net/php-mysql/dom.html Link to comment https://forums.phpfreaks.com/topic/225943-fatal-error/ Share on other sites More sharing options...
trq Posted January 28, 2011 Share Posted January 28, 2011 You need DomDocument not DomComment. Link to comment https://forums.phpfreaks.com/topic/225943-fatal-error/#findComment-1166464 Share on other sites More sharing options...
spangle1187 Posted January 28, 2011 Author Share Posted January 28, 2011 What a tool I am for not spoting that one! Link to comment https://forums.phpfreaks.com/topic/225943-fatal-error/#findComment-1166493 Share on other sites More sharing options...
spangle1187 Posted January 28, 2011 Author Share Posted January 28, 2011 The code is now working and echoing to the screen the data and inthe source view the data is in xml nodes. The next step is to get actionscript to read the xml file and take the data into flash and not echo it to the screen. What procedure would I need to complete this? Link to comment https://forums.phpfreaks.com/topic/225943-fatal-error/#findComment-1166517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.