ResponseXML cannot get results

Source: Internet
Author: User
The error code returned by responseXML is as follows: & lt ;? Php & nbsp; header ('content-Type: text/XML'); header (& quot; Cache-Control: no-cache, must-revalidate & q responseXML cannot get results
The code is as follows:
Header ('content-Type: text/XML ');
Header ("Cache-Control: no-cache, must-revalidate ");

$ Q = $ _ GET ["q"];


// Include_once ("../public/dbManager. php ");
// Include_once ("../public/stringConvert. php ");;


$ Con = mysql_connect ('localhost', 'root', 'root ');
If (! $ Con ){
Die ('could not connect: '. mysql_error ());
}

Mysql_select_db ("ajax_demo", $ con );

$ SQL = "SELECT * FROM user WHERE id =". $ q ."";

$ Result = mysql_query ($ SQL );

Echo'
';
While ($ row = mysql_fetch_array ($ result )){
Echo" ". $ Row ['firstname']." ";
Echo" ". $ Row ['lastname']." ";
Echo "". $ row ['age']."";
Echo" ". $ Row ['Hometown ']." ";
Echo" ". $ Row ['job']." ";
}
Echo" ";

Mysql_close ($ con );
?>

The above code only requires the introduction of other files and comments
// Include_once ("../public/dbManager. php ");
// Include_once ("../public/stringConvert. php ");
.
ResponseXML will not be able to get the result, and execute to xmlDoc. getElementsByTagName ("firstname") [0]. childNodes [0]. nodeValue;
The program is no longer executed.
If the include statement is removed, the program runs normally.
The file introduced above does not have any page output.
I just got in touch with php. please answer this question. thank you.


------ Solution --------------------
Let's see if XML is returned correctly.
------ Solution --------------------
PHP array and xml mutual conversion encapsulation function: xmlparse. php
PHP code
# Convert the array to xmlinclude (dirname (_ FILE __). "/xmlparse. php "); $ listtags = explode (" "," name "); $ arr = array (1," name "=>" SOM "," admin ", 100, array ("name" => "TOM", "Lily"); $ contXML = dump_xml_config ($ arr, "xml", "UTF-8 "); // put the file // file_put_contents_safe ("/path/test. xml ", $ contXML," w "); echo $ contXML; # Source code #
  #
  
   
# <0> 1
   #
   
    
SOM
   # <1> admin
   <2> 100
   # <3> #
   
    
TOM
   # <0> Lily
   #
   #
  
------ Solution --------------------
Header ('content-Type: text/XML ');
Header ("Cache-Control: no-cache, must-revalidate ");
Comment out the two sentences. Open the included files. Enable the error prompt function to check whether an error is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.