kev wood Posted October 10, 2008 Share Posted October 10, 2008 i am trying to convert an php mysql query into an xml formatted page which i can then have flash read and import the data. i keep getting errors though and i have not done this before so i am stuck. here is my code <?php if(!$dbconnect = mysql_connect('localhost', 'flashtest', 'flash')) { echo "Connection failed to the host 'localhost'."; exit; } // if if (!mysql_select_db('flashtestdb')) { echo "Cannot connect to database 'flashtestdb'"; exit; } // if $table_id = 'articles'; $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) { $child = $doc->createElement($fieldname); $child = $occ->appendChild($child); $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } // foreach } // while // get completed xml document $xml_string = $doc->saveXML(); ?> the error i am getting are as follows Warning: domdocument(): Start tag expected, '<' not found in /home/acmeart/public_html/flashtest/getart.php on line 6 Fatal error: Call to undefined function: createelement() in /home/acmeart/public_html/flashtest/getart.php on line 11 any help with this would be great Quote Link to comment Share on other sites More sharing options...
Jibberish Posted October 10, 2008 Share Posted October 10, 2008 What does thr DomDocument class look like? Quote Link to comment Share on other sites More sharing options...
live_to_love Posted October 10, 2008 Share Posted October 10, 2008 PHP is case sensitive. So your DomDocument is not the same as DOMDocument. DomDocument seems not to implement createElement() method. Quote Link to comment Share on other sites More sharing options...
kev wood Posted October 10, 2008 Author Share Posted October 10, 2008 i have got this code from following a tutorial whixh was not explained very well. i have changed the DomDocument to how you stated but i am still getting errors which are as followes Warning: domdocument(): Start tag expected, '<' not found in /home/acmeart/public_html/flashtest/getart.php on line 16 Fatal error: Call to undefined function: createelement() in /home/acmeart/public_html/flashtest/getart.php on line 19 Quote Link to comment Share on other sites More sharing options...
kev wood Posted October 13, 2008 Author Share Posted October 13, 2008 i have now got the page to work with no errors but i dont think that it is converting it to an xml document. when the page is processed this is the output that i get. 20 0000-00-00 text for the cms goes in here 19 0000-00-00 lets have fun with this and get it to work 18 0000-00-00 lets have fun with this and get it to work 17 0000-00-00 lets have fun with this and get it to work 16 0000-00-00 lets have fun with this and get it to work 14 0000-00-00 lets have fun with this and get it to work 15 0000-00-00 lets have fun with this and get it to work 13 0000-00-00 lets have fun with this and get it to work this information should be formatted to xml but it is not. 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.