lanmind Posted May 30, 2009 Share Posted May 30, 2009 Hello,I'm trying to output some XML in PHP based on a database query. The javascript that handles the PHP's response is returning "xmlDoc is null". Here is the PHP's response: <?xml version="1.0" encoding="ISO-8859-1"?><response><results></results></response> Here is the relevant PHP: //Retrieve the user's original question from the answers table and get the answer! $query= "SELECT question, answer, id from answers WHERE id='{$_SESSION['userid']}'"; $originalquestion= mysql_query($query); echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; // Echo Parent Node echo '<response>'; // Start Child Nodes with Results echo '<results>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($originalquestion)) { // ADD TO XML DOCUMENT NODE echo '<result '; echo 'question="' . parseToXML($row['qusetion']) . '" '; echo 'answer="' . parseToXML($row['answer']) . '" '; echo 'id="' . parseToXML($row['id']) . '" '; echo '/>'; } //End Results echo '</results>'; // End XML file echo '</response>'; I'm not sure why the tag "<result>" is not being generated in the XML by the PHP. Thank you for your time. Link to comment Share on other sites More sharing options...
Ingolme Posted May 30, 2009 Share Posted May 30, 2009 Remove the @ from @mysql_fetch_assoc to see if your query has an error, or if there are any rows in the database. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.